http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52688
Daniel Krügler <daniel.kruegler at googlemail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |daniel.kruegler at | |googlemail dot com --- Comment #7 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-01-16 09:03:56 UTC --- I stumbled across a similar problem recently within a member function of a class template: //---------------------------- template<class T> struct A { static bool test() { static bool value = false; if (value) return false; struct S { S() { value = true; } }; static S s; return true; } }; int main() { A<int>::test(); } //---------------------------- "obj\Debug\main.o||In function `A<int>::test()::S::S()':| main.cpp|8|undefined reference to `value'" It doesn't occur if A is not a template. I can confirm the error with gcc 4.7.2 and gcc 4.8.0 20130113 (experimental) compiled with the flags -Wall -pedantic-errors