Re: thread_local broken in gcc 4.8 ?
On Mon, Jan 6, 2014 at 6:25 PM, Jakub Jelinek wrote: > Wonder if the ctor is really trivial it wouldn't be better to treat it as > not needing dynamic initialization, rather than trying to initialize it > dynamically. This is actually a reduced case scenario. In the original case the constructor is not trivial. > So, please file this into bugzilla. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59364
Re: thread_local broken in gcc 4.8 ?
On Mon, Jan 06, 2014 at 03:53:13PM +1000, Conrad S wrote: > According to http://gcc.gnu.org/gcc-4.8/cxx0x_status.html > the keyword "thread_local" is supported in gcc 4.8 when using -std=c++11 Bugs should be reported to http://gcc.gnu.org/bugzilla/ > 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; > } Apparently this got fixed/made latent on the trunk by http://gcc.gnu.org/r199577 , but it isn't clear if that was an intentional bugfix somewhere; in any case the patch doesn't look to be backportable. Wonder if the ctor is really trivial it wouldn't be better to treat it as not needing dynamic initialization, rather than trying to initialize it dynamically. So, please file this into bugzilla. Jakub
thread_local broken in gcc 4.8 ?
According to http://gcc.gnu.org/gcc-4.8/cxx0x_status.html the keyword "thread_local" is supported in gcc 4.8 when using -std=c++11 However, thread_local seems broken. Let's say we compile a multi-file program that uses thread_local: 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 We get the following error: b.o: In function `TLS wrapper function for foo_instance': b.cpp:(.text._ZTW12foo_instance[_ZTW12foo_instance]+0x5): undefined reference to `TLS init function for foo_instance' collect2: error: ld returned 1 exit status gcc --version gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7) 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; }