Re: [cxx-abi-dev] ::delete and deleting destructors
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cxx-abi-dev] ::delete and deleting destructors
- To: Jason Merrill <jason@xxxxxxxxxx>
- Subject: Re: [cxx-abi-dev] ::delete and deleting destructors
- From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
- Date: Wed, 05 Sep 2007 10:06:47 -0700
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@xxxxxxxxxxxxxxxx
(650) 331-3385 x713