This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Accepted as a DR at the July, 2019 meeting.]
According to 6.7.6.5.2 [basic.stc.dynamic.allocation] paragraph 2,
For an allocation function other than a reserved placement allocation function (17.6.3.4 [new.delete.placement]), the pointer returned is suitably aligned so that it can be converted to a pointer to any suitable complete object type (17.6.3.2 [new.delete.single]) and then used to access the object or array in the storage allocated (until the storage is explicitly deallocated by a call to a corresponding deallocation function).
This requirement seems excessive, as it appears to require the strictest fundamental alignment even for objects that are too small to require such an alignment.
Proposed resolution (March, 2019):
Change 6.7.6.5.2 [basic.stc.dynamic.allocation] paragraph 2 as follows:
...The order, contiguity, and initial value of storage allocated by successive calls to an allocation function are unspecified.For an allocation function other than a reserved placement allocation function (17.6.3.4 [new.delete.placement]), the pointer returned is suitably aligned so that it can be converted to a pointer to any suitable complete object type (17.6.3.2 [new.delete.single]) and then used to access the object or array in the storage allocated (until the storage is explicitly deallocated by a call to a corresponding deallocation function).Even if the size of the space requested...
Add the following as a new paragraph to 6.7.6.5.2 [basic.stc.dynamic.allocation] after the existing paragraph 2:
For an allocation function other than a reserved placement allocation function (17.6.3.4 [new.delete.placement]), the pointer returned on a successful call shall represent the address of storage that is aligned as follows:
If the allocation function takes an argument of type std::align_val_t, then the storage will have the alignment specified by the value of this argument.
Otherwise, if the allocation function is named operator new[], then the storage is aligned for any object that does not have new-extended alignment (6.7.3 [basic.align]) and is no larger than the requested size.
Otherwise, the storage is aligned for any object that does not have new-extended alignment and is of the requested size.
Change 17.6.3.2 [new.delete.single] paragraph 1 as follows:
Effects: The allocation functions (6.7.6.5.2 [basic.stc.dynamic.allocation]) called by a new-expression (7.6.2.8 [expr.new]) to allocate size bytes of storage. The second form is called for a type with new-extended alignment, andallocates storage with the specified alignment. Thethe first form is called otherwise, and allocates storage suitably aligned to represent any object of that size provided the object's type does not have new-extended alignment.
Change 17.6.3.3 [new.delete.array] paragraph 1 as follows:
Effects: The allocation functions (6.7.6.5.2 [basic.stc.dynamic.allocation]) called by the array form of a new-expression (7.6.2.8 [expr.new]) to allocate size bytes of storage. The second form is called for a type with new-extended alignment, andallocates storage with the specified alignment. Thethe first form is called otherwise, and allocates storage suitably aligned to represent any array object of that size or smaller, provided the object's type does not have new-extended alignment.218