https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94671
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Bas Vodde from comment #4) > When an operator new gets optimized by the compiler, the framework can't > keep track of the accounting information and the delete call will report > that non-allocated memory was deleted. Obviously memory that wasn't returned from your replacement operator new can't be passed to your replacement operator delete. If calls to operator new are combined into fewer calls, or elided completely, then the compiler is also responsible for combining/eliding the corresponding calls to operator delete. Read the proposal referenced in the Clang bug you linked to: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3433.html I don't see any bug with current GCC 10.0.1 snapshots. If I provide a replacement operator delete then it is only called once, with a pointer that was returned by the single call to operator new.