https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81915

--- Comment #4 from Arthur Norman <acn1 at cam dot ac.uk> ---
Created attachment 47282
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47282&action=edit
static inline thread_local leading to linker failures with Microsoft object
format

This is just a bash script that created fiulr t.h, t1.cpp and t2.cpp then
compiles them and tries to link. On Linux (various varieties) it compiles and
links happily. On Cygwin and with x86_64-w64-mingw32-g++ the link step fails
with multiple definitions of some thread-local initialization despite
everything relevant being "inline".

The original bug report uised std::string in its test case and one might worry
that std::string was special or complicated. This just uses plain data. Also
this is a report for g++ 8.3 (but note again that this is on CYgwin and that
Linux works) so it brings the report up to date.

I observe that if I put the static thread-local dsfs in an inline function not
as inline fields in a class linking succeeds, and that suggests to me that
there is a way to make the Microsoft linker cope with this.

Reply via email to