ABI bug: virtual destructors vs. delete

Mark Mitchell mark at codesourcery.com
Tue Feb 13 02:36:55 UTC 2001


The ABI presently specifies that we must emit all variants (in-charge,
not-in-charge, and deleting) for constructors and destructors, even
when they are not all neeeded.

That is fine, except for the following case:

  struct A  {
    void operator delete (void*);
  };

  struct B {
    void operator delete (void*);
  };

  struct C : public A, public B {
    ~C() {}
  };

In this case, `operator delete' is ambiguous in `C'.  The standard is
OK with this, since `C::~C' is not a virtual destructor.  However, it
doesn't make sense for us to try to embed a call to `operator delete'
in the `C::~C' destructor.

Therefore, we should simply not emit a deleting destructor in this
case. 

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.

The example above should be included in a note.

Alex, if there's no disagreement in the next 48 hours, would you mind
making this change?

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




More information about the cxx-abi-dev mailing list