-
Notifications
You must be signed in to change notification settings - Fork 13.6k
-Wglobal-constructors false positive #8467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That does require a static constructor. When the optimizer is turned on, sometimes it can remove them, but it certainly does at -O0. |
Ah, no, you're right, it's a static in a function, so it is lazily constructed. |
Fixed in r113344. |
When adding a "~Foo() {}" destructor I'm getting also a "global destructor" warning. Is it correct? |
What platform are you on? On some platforms, those do require (conditionalized) global destructors. |
x86_64 GNU/Linux |
Apparently we don't actually pay attention to that. I've disabled the global-destructor warning on static locals for all targets (in r114269) and filed llvm/llvm-bugzilla-archive#8176 to track the target-specific fix. |
[next][llvm] use new noncopyable infrastructure
Extended Description
The following example gives a warning when -Wglobal-constructors is enabled:
struct Foo {
int x;
Foo(int x1) : x(x1) {}
};
void bar() {
static Foo a(0);
}
clang++ output:
a.cpp:8:13: warning: declaration requires a global constructor [-Wglobal-constructors]
static Foo a(0);
^~~
The text was updated successfully, but these errors were encountered: