Continuing from http://gcc.gnu.org/ml/gcc-help/2009-10/msg00087.html
When compiling the following code: g++ test.cpp -o test.o -c -save-temps ---- test.cpp ------------- struct A { static int Init() { static int &i = *new int(); return i; } }; ----------------------- Generated file contains symbol _ZGVZN1A4InitEvE1i (guard variable for i), but not _ZZN1A4InitEvE1i (guarded variable i). Guard variable shouldn't be generated in this case. Since sometimes between 20090611 and 20090618, guard and guarded variables are in the same section group. Linker then (may) generate file with undefined _ZZN1A4InitEvE1i, which causes crash when this variable is accessed. (I hope I understood things correctly) Tested 3.3.6, 3.4.6, 4.1.2, 4.2.4, 4.3.4, 4.4.1, 4.5 Symbol is emitted everywhere, but only in 4.5 it causes crash. -- Summary: guard variable is emitted even when the guarded symbol isn't Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: zsojka at seznam dot cz GCC host triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41611