#include <iostream>
template <class T> class wrapper {
public:
static T get() {
static thread_local T thing(12);
return thing;
}
};
int main() {
std::cout<<wrapper<int>::get()<<std::endl;
}
And I get this, it compile and function as expected using clang++
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Courier; color: #4d2f2d; background-color: #dfdbc3}
span.s1 {font-variant-ligatures: no-common-ligatures}
span.Apple-tab-span {white-space:pre}
icpc -std=c++11 -g thread_local.cc
0 0x10b0cf2c0 __assert_rtn + 129
1 0x10b196eb3 ld::passes::tlvp::doPass(Options const&, ld::Internal&) + 1987
2 0x10b0d016b main + 913
3 0x7fff70f9c015 start + 1
A linker snapshot was created at:
/tmp/a.out-2018-03-19-204307.ld-snapshot
ld: Assertion failed: (0 && "wrong content type for target in tlv defs"), function doPass, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-351.8/src/ld/passes/tlvp.cpp, line 293.