[cxx-abi-dev] ::delete and deleting destructors

Mark Mitchell mark at codesourcery.com
Wed Sep 5 17:06:47 UTC 2007


Jason Merrill wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15097
> 
> seems to indicate a problem with the ABI.  The standard requires that
> ::delete use the global operator delete, but properly deleting an object
> of a type with a virtual destructor requires that use the deleting
> destructor, which will call the operator delete declared in the class,
> if any.

Ugh.

> It seems to me that fixing this would require a change to the ABI

Why can't the code generated by the compiler for "::delete x", where "x"
 is of type "X", a dynamic class, be:

  // Get the virtual table.
  vtbl = *x;
  // Adjust by the offset-to-top.
  p = x + vtbl[-2];
  // Call the non-deleting, complete object destructor.
  // This is a virtual call, so calls the destructor for
  // most-derived type.
  x->X::~X();
  // Call the global deallocation function
  ::operator delete(p);

?

-- 
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713



More information about the cxx-abi-dev mailing list