This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: p2736.C Is dtor order guaranteed?


>>>>> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]