https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81047
Jonathan Wakely changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Jonathan Wakely ---
https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b98-Thread-Local-Edits.html
> The storage for an object of thread storage duration shall be statically
> initialized before the first statement of the thread startup function. An
> object of thread storage duration shall not require dynamic initialization.
So you can't use __thread for objects that require dynamic initialization.
(In reply to Jason Vas Dias from comment #0)
> Incidentally, the error is very confusing - it first claims that it
> is an error to attempt to initialize the TLS variable dynamically, and
> then issues a 'note:' that C++11 supports dynamic initialization of
> TLS objects - but it doesn't ?
Yes it does, but __thread is not part of C++11.
thread_local is part of C++11, and supports what you're trying to do.
__thread and thread_local are not the same thing.