Compiling the following source the compiler crash with the following error:
main.cpp:77: internal compiler error: in output_constant, at varasm.c:3890 // file main.cpp #include <iostream> #include "c.h" int main() { Test<S> t; t.out(); std::cout << "here" << std::endl; return 0; } template <class T> int Test<S>::myInt; template <class T> S& Test<S>::myS = S::instance(); // file c.h class S { public: S() { } ~S() { } S& instance() { static S myS; return myS; } void out() { std::cout << "S" << std::endl; } private: S(const S&); //disabled S operator=(const S&); //disabled }; /////////////////////////////////////// template <class T> class Test { public: Test() { } ~Test() {} static int myInt; static S & myS; static void out() { std::cout << myInt << std::endl; myS.out(); } }; /////////////////////////////////////// //file c.cpp #include <iostream> #include "c.h" /////////////////////////////////////// if you move the initialization of static members from main.cpp in c.cpp then you get a link error ( I don't know if this it's a problem too ). Regards Gaetano Mendola -- Summary: internal compiler error on static member assignment Product: gcc Version: 3.4.3 Status: UNCONFIRMED Severity: critical Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mendola at bigfoot dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20980