ABI bug: virtual destructors vs. delete

Mark Mitchell mark at codesourcery.com
Tue Feb 13 16:51:45 UTC 2001


>>>>> "Jason" == Jason Merrill <jason at redhat.com> writes:

    >> In particular, 5.2.5 should be amended to say:

    >> The deleting variant of a destructor must not be emitted if the
    >> destructor is non-virtual.

    Jason> So 'delete foo;' should call operator delete directly if
    Jason> foo's destructor is non-virtual?

That was my intention; thanks for making it explicit.

    Jason> Another possible solution would be to just suppress the
    Jason> deleting variant if calling op delete would be ill-formed.
    Jason> That's more like what we've done in g++.

That's true -- but more complicated, in that you have to notice the
ambiguity, rather than just keying off the virtuality.  Also, when you
actually call delete, you have to simulate the call (in order to be
sure to issue the error message there), but you then have to actually
call the deleting destructor instead.

The advantage of your scheme would be that you avoid replicating the
call to `operator delete' at each delete site; instead, it appears
only in the deleting destructor, when it exists.

I've already implemented my variant in G++ -- but not checked it in.

I'm cool with either solution -- but I'd like us to make a decision in
short order.  These days that usually seems to come down to you and
me, although of course if anyone else out there has an opinion they
should shout.

What's your preferred solution?

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list