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?


I wrote:

>> init5.C will test for this kind of misbehavior too, but egcs can't
>> currently handle destruction of local static variables interspersed
>> with global variables.

Robert Lipe <robertl@dgii.com> writes:

> I'm confused.   If egcs can't currently handle init5.C, how does this
> tell us anything new?

It doesn't, init5.C is there just to remember us that the current
behavior is non-conforming.  But p2736.C is a much simpler test case,
that checks whether dynamically initialized local objects are only
initialized when control first crosses its declaration, which, in this
case, should be after the global object is initialized.  It also tests
whether destruction takes place in the reverse order of construction,
which works on most ports as long as the initialization of global
objects does not call functions with dynamic initialized local
objects.  Unfortunately, the OpenServer/COFF port does not get it
right.

One possibility is that atexit() (used to destruct the local objects)
is being called at the wrong place, for example, only after global
destructors run.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



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