Date
2019-11-15.00:00:00
Message id
6380

Content

[Accepted as a DR at the November, 2019 meeting.]

According to 7.6.2.8 [expr.new] paragraph 12,

When a new-expression calls an allocation function and that allocation has not been extended, the new-expression passes the amount of space requested to the allocation function as the first argument of type std::size_t . That argument shall be no less than the size of the object being created; it may be greater than the size of the object being created only if the object is an array. For arrays of char, unsigned char, and std::byte, the difference between the result of the new-expression and the address returned by the allocation function shall be an integral multiple of the strictest fundamental alignment requirement (6.7.3 [basic.align]) of any object type whose size is no greater than the size of the array being created.

There is no exemption for the non-allocating (void*,size_t) placement-new allocation function, so programs must allow for the possibility that the provided buffer may need to be larger (by an indeterminate amount) than the size of an array placed into existing storage.

Should the non-allocating placement-new allocation function be exempt from the array allocation overhead? (This question was explicitly referred to CWG by the EWG chair.)