[llvm-bugs] [Bug 24593] New: clang-cl errors on TLS variables in exported static member functions

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 26 15:47:41 PDT 2015


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: unassignedclangbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvm-bugs at 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 at S@@SAHXZ
   /EXPORT:??4S@@QAEAAU0 at ABU0@@Z
   /EXPORT:?x@?1??f at S@@SAHXZ at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150826/ad887663/attachment.html>


More information about the llvm-bugs mailing list