[PATCH] [ms-cxxabi] Emit linkonce complete dtors in TUs that need them

John McCall rjmccall at apple.com
Fri Jul 19 14:02:40 PDT 2013


On Jul 19, 2013, at 1:40 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> On Fri, Jul 19, 2013 at 01:11:18PM -0700, John McCall wrote:
>> On Jul 19, 2013, at 12:28 PM, Reid Kleckner <rnk at google.com> wrote:
>>> +  // XXX: In the Microsoft ABI, we want to emit a delegating complete dtor
>>> +  // without a definition, which means we won't be able to tell if the
>>> +  // definition is a try body.  In this case, MSVC simply delegates, so we do
>>> +  // the same.
>>> 
>>> What is this XXX about?  Is this a FIXME?  It looks like we're actually doing it.
>>> 
>>> I should remove that.  I'm still confused about why destructors defined as try bodies need to be a special case, but the current behavior should be compatible with cl.exe.
>> 
>> You can’t delegate the base construction when there’s a try body and virtual
>> bases because then the try body would appear twice on the stack.
> 
> Well, cl.exe seems to delegate it anyway.  This seems to be a
> deficiency in the ABI.  I remember running an experiment in which a
> destructor throws an exception caught in the try body of a virtually
> derived class.  This caused the program (compiled with cl.exe)
> to segfault.
> 
> We might want to issue a warning if we see a destructor of a class with
> virtual bases defined using a try body when compiling for this ABI.

We can make an effort to do the right thing, e.g. if the destructor has an
inline definition (which, by the ODR, is something that all translation units
agree on);  but yes, I think if we see a non-inline destructor definition
with a function-try-body and non-trivially-destructable virtual bases, we
should warn.

John.



More information about the cfe-commits mailing list