https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60702
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2017-11-15 00:00:00 |2018-10-25 See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=81880 --- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- Another wrong-code example taken from https://gcc.gnu.org/ml/gcc-help/2018-10/msg00116.html class B { int* x; public: static thread_local B tmp; B() { x = new int(); } void f() { *x = 0; } }; thread_local B B::tmp; template<class T> void f() { B::tmp.f(); } void g() { B::tmp.f(); } int main() { //g(); f<int>(); } Unless the non-template g() is called first, the thread_local variable isn't initialized.