p2736.C Is dtor order guaranteed?
Jason Merrill
jason@cygnus.com
Wed Jul 22 01:59:00 GMT 1998
>>>>> Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:
>> It doesn't, init5.C is there just to remember us that the current
>> behavior is non-conforming.
> From looking at the standard, it seems that the only acceptable
> implementation of global destructors is one that uses atexit for
> global objects as well.
> I.e., when a static namespace-scoped object has been successfully
> constructed, register a function with atexit that will destroy the
> object.
> Would such an implementation be conforming?
Well, yes and no. Yes, it would conform to the ordering restrictions.
However, an implementation is allowed to have a limit of 32 functions
registered with atexit, and we can't put that kind of limit on global
objects. We shouldn't put it on local statics either, but that is
currently the case. Also, it would make the current situation with
dynamically loaded objects even worse.
As far as I can tell, the only complete solution involves replacing atexit.
Jason
More information about the Gcc
mailing list