[Bug c++/17910] New: wrong order of static initialization
kunert at physik dot tu-dresden dot de
gcc-bugzilla@gcc.gnu.org
Sat Oct 9 13:27:00 GMT 2004
#include <iostream>
using namespace std;
struct A {
int x;
A(){ x = 17; }
};
template<class T>
struct B {
static A a;
int x;
B(){ x = a.x; }
};
template<class T>
A B<T>::a;
B<int> b;
int main()
{
cout << b.x << ' ' << b.a.x << endl;
}
The abould code should initialize B<int>::a before the global static b,
resulting in '17 17'. However, the actual output is '0 17'.
--
Summary: wrong order of static initialization
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: kunert at physik dot tu-dresden dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17910
More information about the Gcc-bugs
mailing list