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: static constructors/destructors and atexit



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


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