[llvm-bugs] [Bug 35237] New: __thread in template does not compile
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Nov 7 16:36:42 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35237
Bug ID: 35237
Summary: __thread in template does not compile
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: oranevskyy at accesssoftek.com
CC: llvm-bugs at lists.llvm.org
test.cpp:
template<typename T>
void test()
{
static __thread T my(555);
}
void foo()
{
test<int>();
}
Compilation:
clang++ -c -std=c++11 test.cpp
Output:
test.cpp:4:23: error: initializer for thread-local
variable must be a constant expression
static __thread T my(555);
^~~~~
test.cpp:4:21: note: use 'thread_local' to allow
this
static __thread T my(555);
Gcc compiles this with no error.
As T is a dependent type clang does not "unfold" the ParenListExpr and treats
it as an initializer, i.e.
`-ParenListExpr 0xb40b31c650 <col:23, col:27> 'NULL TYPE'
`-IntegerLiteral 0xb40b31c5f8 <col:24> 'int' 555
Expr::isConstantInitializer() considers such expressions as non-const, hence
the error.
--
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/20171108/fd9ce6c1/attachment.html>
More information about the llvm-bugs
mailing list