The "placement new" operator is declared as such:
void* operator new (std::size_t size, void* ptr) noexcept;
But while it doesn't involve any actual allocation so bad allocation exceptions are eliminated, it is still possible that the pointer points to a bad location, in which case one would expect to get a range or over/underflow error, but won't the fact that it was declared as noexcept simply terminate execution instead?
Also does this mean prior to C++11 placement new will throw and try to handle an std::unexpected in case of std::set_unexpected instead of directly crashing?
Shouldn't there be a throwing overload of placement new "just in case"?
Placement
newexists to make possible explicit constructor calls targeted into arbitrary buffers (for custom allocators, debugging, etc...). That's about it.You can write your own that validates its input.
For example: A class might require some kind of alignment, and you suspect some custom allocator of fudging this up. So, you give the class a different placement new and see what happens when said allocator uses it.