p2736.C Is dtor order guaranteed?

Martin von Loewis martin@mira.isdn.cs.tu-berlin.de
Wed Jul 22 09:54:00 GMT 1998


> As far as I can tell, the only complete solution involves replacing atexit.

Yes, I've seen this restriction. I think that autoconf could determine
whether the system accepts at least 64 or so atexit calls; in
addition, we could make a list of systems where atexit is known to be
broken.

Alternatively, we could make a list of systems where we know that
atexit has no such restriction.

In any case, we should not too aggressively replace the atexit
implementation, as that might interfere with the native implementation
for some "C" libraries.

Also, some optimization might be applied. Given

struct X()
{
  X(){ next=first;first=this; etc }
  ~X(){ unchain us }
}

X a;
X b;

both a and b need to be destroyed, but we could make a single call to
atexit as we know atexit won't be called between constructing a and b.

Martin



More information about the Gcc mailing list