-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Closed
Copy link
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"extension:gnu
Description
| Bugzilla Link | 46059 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @zygoloid |
Extended Description
NEVER FIXED: #20297
Breaks patterns for creating self registering code modules; which happens to also go hand in hand with pattern use cases for P0424R0/P0424R1.
Using "inline static" will not ensure the static variable is defined.
In fact, the compiler will analyze and remove the static if it thinks it is unreachable.
This creates the need to do horrible things like declare static extern export functions that reference the inline static to ensure it is not elided. Which is total crap and pollution of the COFF/ELF/PE exports!
struct Base {
inline static Base* pHead = nullptr;
static void DoRuntimeActions() {
for(auto p = pHead; p; p = p->pPrev) p->onRuntimeAction();
}
Base* pPrev;
Base() { pPrev = pHead; pHead = this; }
virtual void onRuntimeAction() = 0;
}
struct Foo : Base {
[[gnu::used]] /* NO SUPPORTED IN CLANG!!!! */
inline static Foo s; // SO, no way to guarantee it will exist
/* leverage static singleton registration pattern BROKEN */
virtual void onRuntimeAction() { /* do something useful */ }
}Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++17clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"extension:gnu