Repository navigation
thread_local variables in class scope fail to compile when optimized #208
Closed
ilazaric
started this conversation in
Issue Triage - Compilation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
When using thread local variables in class scope, with optimizations,
compilation fails with error
undefined reference to `__tls_init'Reproducing Source Code
struct S {
S() {}
};
struct T {
inline static thread_local S s{};
};
int main() { (void)T::s; }
Command-line Options
cpfe -O1 repro.cpp
Type of Issue
[Back End] There is a problem with the generated C code.
Additional Details
Compiling repro, error:
https://godbolt.org/z/5MeKsbjTr
Looking at the emitted C, a bit reduced: https://godbolt.org/z/rMWzPxz4q
I think GCC doesn't understand
__asm__("_ZTHN1T1sE = __tls_init");, thinks__tls_initis unused.Adding
__attribute__((__used__))to__tls_initworks: https://godbolt.org/z/coq3Esvc9Reproducing (Standard) Configuration(s)
linux-gcc-release
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions