------- Comment #7 from fang at csl dot cornell dot edu 2007-03-08 23:41 ------- Subject: Re: Overloaded operator delete[] doesn't get called
> Above, in operator new[], If WTF is false, returning NULL, I reproduce the > same error (missing call to class operator delete []). If WTF is true > (returning pool), the right operator delete [] is called. > > // output with WTF false > class new[] operator > > // output with WTF true > class new[] operator > class delete[] operator > > Tested on: powerpc-apple-darwin8-g++-4.0.1 The same result ALSO happens if I de-inline the class operator new/delete [], and compile their definitions in a different translation unit: ------------->8 snip 8<------------------- // de-inlined class definitions #include <iostream> #include "one_array_only.h" using std::cout; bool one_array_only::allocated = false; one_array_only one_array_only::pool[256]; void* one_array_only::operator new[] (std::size_t size) throw() { cout << "class new[] operator\n"; #if WTF return pool; // does not trigger bug #else return NULL; // triggers bug: no operator delete[] called #endif } void one_array_only::operator delete[] (void *p) throw() { cout << "class delete[] operator\n"; } ------------->8 snip 8<------------------- The main translation unit is still calling one_array_only::operator delete[](void*) (from an asm dump). This suggests that one_array_only::operator delete[] is somehow being mis-compiled. Fang -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29164