Created on 2025-11-18.00:00:00 last changed 3 days ago
Proposed resolution:
This wording is relative to N5014.
Modify [new.syn] as indicated:
constexpr void* operator new (std::size_t size, void* ptr) noexcept; constexpr void* operator new[](std::size_t size, void* ptr) noexcept; constexpr void operator delete (void* ptr, void*) noexcept; constexpr void operator delete[](void* ptr, void*) noexcept;
Modify [new.delete.placement] as indicated:
constexpr void* operator new(std::size_t size, void* ptr) noexcept;[…]
constexpr void* operator new[](std::size_t size, void* ptr) noexcept;[…]
constexpr void operator delete(void* ptr, void*) noexcept;-7- Effects: Intentionally performs no action.
-8- Remarks: Default function called when any part of the initialization in a placement new-expression that invokes the library's non-array placement operator new terminates by throwing an exception ([expr.new]).
constexpr void operator delete[](void* ptr, void*) noexcept;-9- Effects: Intentionally performs no action.
-10- Remarks: Default function called when any part of the initialization in a placement new-expression that invokes the library's array placement operator new terminates by throwing an exception ([expr.new]).
The P2747R2 paper made placement operator new constexpr. At that time constexpr exceptions weren't in C++26, so that was all that was needed. But later on when P3068R5 was voted in, the P2747R2 changes look insufficient. The problem is that when you throw from a constructor during operator new, it invokes placement operator delete. And P2747R2 didn't touch that.
This makes it impossible to handle an exception thrown by a placement new-expression during constant evaluation.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-18 13:36:18 | admin | set | messages: + msg15752 |
| 2025-11-18 00:00:00 | admin | create | |