[cxx-abi-dev] When to emit deleting destructor

Mark Mitchell mark at codesourcery.com
Wed Oct 16 14:55:40 UTC 2002


>   [3] Change deleting destructors for non-virtual destructors to be
> optional and caller-produced (in it own COMDAT group) like the allocating
> constructors (C3).

The ways you can make use of such a thing are very limited.  (I think
you know this, but just so that everyone understands the implications...)

If you ever emit a call to the optional deleting destructor, you are
depending on the deleting destructor being around, which you can't be
sure will happen if some other compiler compiles the destructor.  So,
this works only when the destructor definition is visible to you at the
time that you are processing the delete expression.

But, in that case, you can always do whatever you want anyhow; there's
nothing to stop a compiler from inlining the call completely, or
creating a function with internal linkage that combines the delete call
and the destructor call.

So, the only benefit to your proposal is that by giving a standard name
to the destructor, there is a way for callers to collapse those functions 
across translation units.

I don't object to that, I don't suppose.

>> This is a good question; it is unspecified at present.
>>
>> G++'s D0 destructors do not handle a NULL this pointer.
>>
>> What do HP and Intel do?

Yes; we never heard from HP and Intel.  HP, Intel?

> I think the best resolution is that deleting destructors for virtual
> destructors may assume this != 0 and deleting destructors for non-virtual
> destructors must handle this == 0.

Why do you think that is best?  (I don't mean to be argumentative; I'm
just curious why you came to this conclusion.)

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



More information about the cxx-abi-dev mailing list