https://llvm.org/bugs/show_bug.cgi?id=24593
Bug ID: 24593 Summary: clang-cl errors on TLS variables in exported static member functions Product: clang Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: h...@chromium.org CC: llvm-bugs@lists.llvm.org Classification: Unclassified At first, MSVC appears to not allow dllexporting thread-local variables: int __declspec(thread) __declspec(dllexport) x = 42 a.cc d:\src\tmp\a.cc(1) : error C2492: 'x' : 'thread' data may not have dll interface However, if the variable is exported because it's a static local of an exported static member function, it seems to be OK: struct __declspec(dllexport) S { static int f() { static int __declspec(thread) x = 42; return x; } } (no error) Note that x is still getting exported: Linker Directives ----------------- /DEFAULTLIB:LIBCMT /DEFAULTLIB:OLDNAMES /EXPORT:?f@S@@SAHXZ /EXPORT:??4S@@QAEAAU0@ABU0@@Z /EXPORT:?x@?1??f@S@@SAHXZ@4HA,DATA <--- x However, clang-cl doesn't allow that code: d:\src\tmp\a.cc(3,35) : error: 'x' cannot be thread local when declared 'dllexport' static int __declspec(thread) x = 42; ^ This comes up in protobuf: https://github.com/google/protobuf/blob/5021c4d88506ac19be4302be02c3cd1702f97d03/src/google/protobuf/arena.h#L528 -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs