[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 --- Comment #9 from Laurent Rineau --- I still get the compilation error with gcc version 9.1.1.
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 Marc Glisse changed: What|Removed |Added Last reconfirmed|2015-12-16 00:00:00 |2018-2-28 --- Comment #8 from Marc Glisse --- c_parse_final_cleanups calls handle_tls_init several times in the "do ... while(reconsider)" loop. With a single static thread_local, we get lucky and the second time prune_vars_needing_no_initialization returns NULL for an early exit. Otherwise, the function really doesn't look ready for a second call. static_aggregates has a more complicated handling than tls_aggregates.
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 --- Comment #7 from Jason Vas Dias --- And there is no workaround, really - one cannot initialize a C++ class object member of a static thread_local C++ template class object member in one place, outside the class, and use that same object in a non-static member function of the template class, and instantiate another instance of the same template (with different parameters) in the same translation unit - re-declaration in each using member function allows compilation to succeed, but just hides the static class member, so you can't actually use the single initialized static member in a non-static member function. So you HAVE to access thread_local static class members ONLY through pointers ? I will try this.
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 --- Comment #6 from Jason Vas Dias --- (In reply to Jason Vas Dias from comment #5) > It also happens with GCC 5.4.0 - Also happens in GCC 6.3.0 .
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 Jason Vas Dias changed: What|Removed |Added CC||jason.vas.dias at gmail dot com --- Comment #5 from Jason Vas Dias --- Very glad to find this bug, enabling my sanity to be preserved . It also happens with GCC 5.4.0 - and yes, re-declaring as 'static thread_local' in each member function that uses a static thread_local class member object appears to be the only workaround - thanks! I hope this is fixed in 7.1 ...
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 Oleg Pronin changed: What|Removed |Added CC||syber at crazypanda dot ru --- Comment #4 from Oleg Pronin --- (In reply to Laurent Rineau from comment #3) > I got hit by this bug today. Do you know a workaround? Yes. Use static thread_local inside static member function. template struct A { virtual void foo() { v(); } static Heavy& v () { static thread_local Heavy obj; return obj; } }; However i discovered that perfomance of getting thread_local variables somewhy depends on the class (Heavy) in this case, it's size and constructor complexity maybe i dunno, however i benchmarked the code above for some my class and got just only 100M/s calls. After that i changed the code above to: template struct A { virtual void foo() { v(); } static Heavy* v () { static thread_local Heavy* ptr; if (!ptr) { static thread_local Heavy inst; ptr = } return ptr; } }; and got 300M/s calls. The point is that you should not allow code flow to go through static thread_local object declaration itself, only through POD pointer type. I don't know why thread_local is so ineffective however this workaround gave x3 speed for me in GCC 4.9 In clang, there is no thread_local bug, however it's speed is always slow (100M/s) and i could not speedup it with any of workarounds :(
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 Laurent Rineau changed: What|Removed |Added CC||Laurent.Rineau__gcc@normale ||sup.org --- Comment #3 from Laurent Rineau --- I got hit by this bug today. Do you know a workaround?
[Bug c++/66944] ICE on static thread_local member in class template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66944 Andrew Pinski changed: What|Removed |Added Summary|[6 regression] ICE on |ICE on static thread_local |static thread_local member |member in class template |in class template | Severity|major |normal --- Comment #2 from Andrew Pinski --- >Today's trunk crashes with the following ICE so making this a regression: Except the previous versions also ICEd. That is what: bug.cc:14: confused by earlier errors, bailing out Is about really.