This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: p2736.C Is dtor order guaranteed?
- To: Marco dot Franzen at Thyron dot com
- Subject: Re: p2736.C Is dtor order guaranteed?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Sat, 26 Aug 2000 02:43:32 +0200
- CC: gcc at gcc dot gnu dot org
- References: <00082515321800.00557@Maidavale>
> Would such use of atexit be within its (POSIX?) specification?
> For example, on HP-UX 10.20 the manual entry for atexit says:
>
> An atexit() call during exit processing is always unsuccessful.
>
> If a function with local static object is called the first time from the
> destructor of another static (function or not) object, the mechanism
> wouldn't work (on HP, at least).
Even if I can't find exact wording for that, I'd expect this case to
have undefined behaviour in C++, as well (i.e. construction of an
object with static storage duration after exit has been called).
> Would that object (have to be) constructed and destroyed again or is that
> undefined behaviour?
That is undefined as per 3.6.3/2:
# If a function contains a local object of static storage duration
# that has been destroyed and the function is called during the
# destruction of an object with static storage duration, the program
# has undefined behavior if the flow of control passes through the
# definition of the previously destroyed local object.
> Do gcc's destructors set the "initialised" flag to false on
> destruction so that it is constructed (and destroyed if atexit
> works) again?
I don't think it does.
Martin