Date: Wed, 21 Jan 2026 22:18:43 +0000
Take a look at the assembly of this code, it looks pretty good right? Just 4 mov and a ret
https://godbolt.org/z/bPh8KhjW5
Now, uncomment #define SHOWBAD (in my.h) and see why I never use thread_local
Could we fix this somehow? In the link below, someone has written an explanation of the problem.
In short, the problem is that we can't see how it's initialized
https://discourse.llvm.org/t/whats-with-thread-local-calling-an-initalizer/89459/6
I was thinking about allowing something like `extern MyClass myObj{i, promise, to, init, like, _this_};`
However, this may break some behavior. Maybe we can initiate by writing
`[[extern]] MyClass myObj{i, promise, to, init, like, _this_};`
Or
`[[no_initalizer]] extern MyClass myObj;`
Or have some kind of rule so it isn't dynamically initialized.
I get into situations where I can't use the gcc __thread attribute, and it occasionally is annoying
How should we fix this? It’s a problem in both gcc and clang
https://godbolt.org/z/bPh8KhjW5
Now, uncomment #define SHOWBAD (in my.h) and see why I never use thread_local
Could we fix this somehow? In the link below, someone has written an explanation of the problem.
In short, the problem is that we can't see how it's initialized
https://discourse.llvm.org/t/whats-with-thread-local-calling-an-initalizer/89459/6
I was thinking about allowing something like `extern MyClass myObj{i, promise, to, init, like, _this_};`
However, this may break some behavior. Maybe we can initiate by writing
`[[extern]] MyClass myObj{i, promise, to, init, like, _this_};`
Or
`[[no_initalizer]] extern MyClass myObj;`
Or have some kind of rule so it isn't dynamically initialized.
I get into situations where I can't use the gcc __thread attribute, and it occasionally is annoying
How should we fix this? It’s a problem in both gcc and clang
Received on 2026-01-21 22:18:44
