<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - clang-cl errors on TLS variables in exported static member functions"
href="https://llvm.org/bugs/show_bug.cgi?id=24593">24593</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-cl errors on TLS variables in exported static member functions
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>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:
<a href="https://github.com/google/protobuf/blob/5021c4d88506ac19be4302be02c3cd1702f97d03/src/google/protobuf/arena.h#L528">https://github.com/google/protobuf/blob/5021c4d88506ac19be4302be02c3cd1702f97d03/src/google/protobuf/arena.h#L528</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>