https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109770
m.cencora at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.cencora at gmail dot com --- Comment #6 from m.cencora at gmail dot com --- (In reply to Richard Biener from comment #0) > #include <new> > > struct Base > { > virtual ~Base() {} > }; > struct A : Base > { > virtual ~A() {} > }; > struct B : Base > { > [[gnu::noinline]] B() { new (this) A; } > virtual ~B() { __builtin_abort (); } > }; > int main() > { > Base *p = new B; > delete p; > } > > aborts when compiled with -O2 (with devirtualization enabled). Neither > GCC nor clang diagnose the placement new in B::B() (but it looks fishy). I believe you need to std::launder the p pointer before calling delete: https://en.cppreference.com/w/cpp/utility/launder