http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55800
Bug #: 55800 Summary: Link failure with thread_local in unnamed namespace Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: vlu...@gmx.de Considering this snippet: ------------------------------------------------------- namespace { struct X { X() { } }; thread_local X x; } int main() { x; } ----------------------------------------------------- Compiling with "c++ -std=c++0x" results in: ---------------------------------------------------- /tmp/cceAUNGB.o: In function `_ZTWN12_GLOBAL__N_11xE': thread_local.link_failure.with_main.cc:(.text+0x55): undefined reference to `_ZTHN12_GLOBAL__N_11xE' collect2: error: ld returned 1 exit status ------------------------------------------------------ Output of c++ -v is: ----------------------------------------------------------- Using built-in specs. COLLECT_GCC=/home/lima/vanilla_installs/gcc_and_tools/bin/c++ COLLECT_LTO_WRAPPER=/home/lima/vanilla_installs/gcc_and_tools/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc_svn/configure --prefix=/home/lima/vanilla_installs/gcc_and_tools --enable-__cxa_atexit --enable-languages=c,c++ --disable-nls --disable-multilib Thread model: posix gcc version 4.8.0 20121223 (experimental) (GCC) -----------------------------------------------------------