[PATCH] D66122: [CodeGen] Emit dynamic initializers for static TLS vars in outlined scopes
Eli Friedman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 13 09:02:39 PDT 2019
efriedma added a comment.
> If variable A's initializer references variable B, then it will call B's initializer.
I'm considering a testcase like this:
struct S { int x; };
void bar(S**);
void baz(void());
void f() {
thread_local S s = {1};
thread_local S* p = &s;
baz([]{bar(&p);});
}
The initializer for `p` normally just assumes `s` is initialized. I don't think this patch adds any code that would address that, although I could be missing something.
--------
Thinking about it a bit more, I also have a general question: how is this supposed to work? What do other compilers do? Does the C++ standard say when the initializer is supposed to run? [stmt.dcl]p4 just says "Dynamic initialization [...] is performed the first time control passes through its declaration."
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66122/new/
https://reviews.llvm.org/D66122
More information about the cfe-commits
mailing list