This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: static constructors/destructors and atexit
- To: parkes at sierravista dot com (Steven Parkes)
- Subject: Re: static constructors/destructors and atexit
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Tue, 11 Aug 98 17:59:23 PDT
- Cc: tv at pobox dot com, oliva at dcc dot unicamp dot br, egcs at cygnus dot com
> As someone mentioned, this is not standards-conforming. The standard
> requires that local static destruction be interleaved with atexit()
> callbacks and this won't do that.
We can conform to the standard simply by using atexit() to do local
static destruction. On systems that restrict atexit to 32 handlers,
we can then handle at most 32-N local static variables that have
destructors. So we conform but have a rather low limit as to size
of problem. There can then be a flag to handle larger numbers of
destructors in a non-standard-conformant way (just do them in reverse
order of construction, ignoring atexit).
This number can be increased somewhat by using the as-if rule. If there is
a destructor, but it has no side effects (and we know this because the
body is inline), it can be destroyed by some other mechanism than atexit.