This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Pending NAD status.
Section: 17.6.3.4 [new.delete.placement] Status: Pending NAD Submitter: Marc Glisse Opened: 2013-09-12 Last modified: 2017-09-07
Priority: 2
View all other issues in [new.delete.placement].
View all issues with Pending NAD status.
Discussion:
Based on this discussion and as discussed in c++std-core-23998 and c++std-lib-34442, calling placement new currently forces the compiler to check if the pointer is null before initializing the object (a non-negligible cost). It seems many people were not aware of this and they consider it a user error to pass a null pointer to it.
Proposed resolution: foroperator new
and operator new[]
, add:
Requires:
ptr
shall not be a null pointer.
[2014-02-15 post-Issaquah session : move to Tentatively NAD]
AJM to supply the rationale...
Proposed resolution:
This wording is relative to N3691.
Change 17.6.3.4 [new.delete.placement] as indicated:
void* operator new(std::size_t size, void* ptr) noexcept;-?- Requires:
-2- Returns:ptr
shall not be a null pointer.ptr
. -3- Remarks: Intentionally performs no other action. -4- [Example: This can be useful for constructing an object at a known address:void* place = operator new(sizeof(Something)); Something* p = new (place) Something();— end example]
void* operator new[](std::size_t size, void* ptr) noexcept;-?- Requires:
-5- Returns:ptr
shall not be a null pointer.ptr
. -6- Remarks: Intentionally performs no other action.