https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100495
Bug ID: 100495 Summary: constexpr virtual destructor incorrectly reports memory leak Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldalessandro at gmail dot com Target Milestone: --- When using a constexpr virtual destructor gcc fails to match delete with corresponding new. ``` struct Foo { constexpr virtual ~Foo() {} }; constexpr bool foo() { Foo *ptr = new Foo(); delete ptr; return true; } static_assert(foo()); //error: 'foo()' is not a constant expression because allocated storage has not been deallocated ``` https://godbolt.org/z/W6haTEvzs