9683 – [3.2 regression] bug in initialization chains for static const variables from template classes (original) (raw)
Initialization chains of static const variables in templates does not work properly. If a variable is initialized by a chain of two variables, neither of which is referenced, then the intialization does not occur.
template const int foo::a = 1; template const int foo::b = a; template const int foo::c = b; template const int foo::d = c;
c and d will not be initialized properly if a and b are not used. If a is used, c will be initiailized, but d will not be.
Release: 3.2.1
Environment: slackware-current Configured with: ../gcc-3.2.1/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i386-slackware-linux --host=i386-slackware-linux Thread model: posix gcc version 3.2.1
How-To-Repeat:
hades:/project/gcc-bug> g++ bug1.cc/project/gcc-bug> ./a.out
hades:
0
0
hades:/project/gcc-bug> g++ -DA_C bug1.cc
hades:/project/gcc-bug> ./a.out
1
1
hades:/project/gcc-bug> g++ -DA_D bug1.cc
hades:/project/gcc-bug> ./a.out
1
0
Comment 2 Wolfgang Bangerth 2003-02-14 21:29:45 UTC
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. A regression in 3.2/3.3/3.4 against 2.95. It also fails in 3.0.4, by the way.
May or may not be related to 9674.
W.Comment 7 Joe Buck 2003-04-25 19:59:58 UTC
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed for the next release (3.3).