Optimisation wrongly removes global objet construction/destruction
Gabriel Dos_Reis
Gabriel.Dos_Reis@sophia.inria.fr
Wed May 5 07:34:00 GMT 1999
current CVS EGCS/g++ appears to wrongly remove text definition for
contruction/destruction of global objects. The problem shows up when
compilinig with -Ox, whith x > 2, on a solaris-2.[56]. Below is a
testcase:
poivre% cat a.C
void f() {}
struct X {
~X() { f (); }
};
X x;
poivre% g++ -v; g++ -O3 -c a.C; nm a.o
Reading specs from
/BASE/dosreis/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.93.21/specs
gcc version egcs-2.93.21 19990504 (gcc2 ss-980929 experimental)
U _GLOBAL_.D.x
U _GLOBAL_.I.x
0000000000000000 ? __FRAME_BEGIN__
0000000000000000 t __static_initialization_and_destruction_0
0000000000000018 t __static_initialization_and_destruction_1
0000000000000010 T f__Fv
0000000000000000 t gcc2_compiled.
0000000000000000 B x
Whereas
poivre% g++ -v; g++ -O2 -c a.C; nm a.o
Reading specs from
/BASE/dosreis/EGCS/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.93.21/specs
gcc version egcs-2.93.21 19990504 (gcc2 ss-980929 experimental)
0000000000000068 t _GLOBAL_.D.f__Fv
0000000000000040 t _GLOBAL_.I.f__Fv
0000000000000000 ? __FRAME_BEGIN__
0000000000000008 t __static_initialization_and_destruction_0
0000000000000038 t __static_initialization_and_destruction_1
0000000000000000 T f__Fv
0000000000000000 t gcc2_compiled.
0000000000000000 B x
As a side effect building libstdc++ with -O3 gives an unusable library
since construction/destruction of io_defs__ (from libio/streambuf.cc)
are undefined although referenced.
-- Gaby
More information about the Gcc-bugs
mailing list