p2736.C Is dtor order guaranteed?
Mike Stump
mrs@wrs.com
Mon Jul 20 21:09:00 GMT 1998
> Date: Sat, 18 Jul 1998 22:33:24 -0500
> From: Robert Lipe <robertl@dgii.com>
> To: egcs@cygnus.com
> This target calls both constructors and both destructors. It, however,
> doesn't do them in the order that this testcase likes.
The port needs fixing then.
> Does the language spec really guarantee the order of destructors as
> they're called?
Yes. Anyway, even if it didn't, sometimes we make guarantees that go
beyond the exact spec of the standard and put in testcases to ensure
that something works the same way consistently across all targets.
Think about thread testcases and EH, sure the standard doesn't say
anything, so we don't have to do anything in particular, but we
believe the compiler is better off and users are better off with
additional support.
> The comments at the top about it being a "poor test case" make
> me wonder.
No, the style is poor and hard to maintain and read, and I would like
to develop the style and refine it, but failing that, I believe it is
better to test in the style as shown in that testcase. In someone has
a better way to test everything that testcase tests, I'd love to hear
it.
> > From: Alexandre Oliva (oliva@dcc.unicamp.br)
> > so p2736.C may even be dropped.
No, I am against this.
> > egcs can't currently handle destruction of local static variables
> > interspersed with global variables.
I thought it did on some targets as I recall. I believe I put in some
code to chain them via atexit:
Mon Dec 11 18:56:14 1995 Mike Stump <mrs@cygnus.com>
* cp-tree.h (build_cleanup): New routine to build cleanups.
* decl.c (expand_static_init): Use build_cleanup to build a cleanup
call at ctor time and use atexit to run it later.
* decl2.c (build_cleanup): New routine, taken from finish_file.
(finish_file): Use build_cleanup instead, and don't put function
local statics in global dtor list.
Any port that tries to have a list of dtors is doomed as I recall.
More information about the Gcc
mailing list