C++20 introduces the concept of a "destroying operator delete", as described below:
delete-expressions does not execute the destructor for *p before placing a call to operator delete
So, given the following struct S
:
struct S {
void operator delete(S* p, std::destroying_delete_t);
private:
~S();
};
I'd expect the delete
below to not insert a call to destructor but just call destroying operator delete we provided
delete new S;
However, GCC/Clang/MSVC behave differently: DEMO
Only GCC doesn't try to access ~S()
, others still require ~S()
being accessible.
Which one is correct?