This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17910] New: wrong order of static initialization
- From: "kunert at physik dot tu-dresden dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Oct 2004 13:27:35 -0000
- Subject: [Bug c++/17910] New: wrong order of static initialization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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