When to emit deleting destructor
Mark Mitchell
mark at codesourcery.com
Tue Oct 15 22:52:22 UTC 2002
The current ABI document says:
That is, user-defined constructors or destructors, unless the
function is declared inline, or has internal linkage, are emitted
where defined, with their complete, and base object variants. For
destructors, the deleting variant is emitted as well.
The reason is that in the C++ standard, we have:
[class.dtor]
At the point of definition of a virtual destructor (including an
implicit definition (_class.copy_)), non-placement operator delete
shall be looked up in the scope of the destructor's class
(_basic.lookup.unqual_) and if found shall be accessible and
unambiguous.
There's no guarantee that operator delete will be unambiguous in a
non-virtual destructor, and it therefore doesn't make sense to
generate a deleting destructor in that case.
If I do not hear objections over the next couple of days, I will
modify the sentence above to read:
For virtual destructures, the deleting variant is emitted as well.
(FWIW, G++ already omits the delting destructor if the destructor is
non-virtual.)
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the cxx-abi-dev
mailing list