[Bug c++/59364] C++11 extern thread_local breaks linking: undefined reference to TLS init function

conradsand.arma at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 10 07:06:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364

--- Comment #3 from Conrad <conradsand.arma at gmail dot com> ---
Reduced test case.  Compile with:

g++ a.cpp -c -o a.o -std=c++11
g++ b.cpp -c -o b.o -std=c++11
g++ a.o b.o -o prog -std=c++11

file foo.hpp:

class foo
  {
  public:

  inline  foo() {}
  inline ~foo() {}

  inline double bar() { return 123.456; }
  };


file a.cpp:

#include "foo.hpp"
thread_local foo foo_instance;


file b.cpp:

#include "foo.hpp"
extern thread_local foo foo_instance;

int main(int argc, char** argv)
  {
  double bar = foo_instance.bar();
  return 0;
  }



More information about the Gcc-bugs mailing list