Summary: | thread_local link error | ||
---|---|---|---|
Product: | gcc | Reporter: | Conrad S <conradsand.arma> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | major | CC: | daniel.kruegler, hubicka, jakub, jakub, jason, jason, oleg, victor.dyachenko |
Priority: | P3 | ||
Version: | 4.8.2 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | 4.9.0 | |
Known to fail: | 4.8.2 | Last reconfirmed: | |
Bug Depends on: | |||
Bug Blocks: | 59994 | ||
Attachments: | reduced test case |
Description
Conrad S
2013-12-02 02:30:48 UTC
This seems to be a duplicate of bug #55800. The workaround mentioned in the comments fixes the problem. I wouldn't call the method presented in the comments to bug #55800 as a workaround. Quote: "at least adding .globl _ZTWN3xyz3blaE _ZTWN3xyz3blaE = __tls_init manually at the end of the assembly seems to make the code do what it is supposed to" Editing the assembly is not a workaround -- it's a one off hack. 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; } Created attachment 31406 [details]
reduced test case
Attached reduced_test_case.tar.gz
No need for pre-processed input, as it doesn't include any system headers.
Works in 4.9. Any chance of a backport of this fix to gcc 4.8.3 ? I thought I've commented on this, perhaps in other PR, but can't find it right now. The link error disappeared with r199577, which certainly doesn't seem to be backportable nor a change with the intent to fix this, and furthermore, I'd say that for such a trivial (sure, not in C++ terminology) ctor we'd better not to require dynamic initialization of the TLS var. |