https://bugs.llvm.org/show_bug.cgi?id=46059
Bug ID: 46059
Summary: [[gnu::used]] unsupported. Breaks many "inline static"
use cases including P0424R0.
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++17
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
NEVER FIXED: https://bugs.llvm.org/show_bug.cgi?id=19923
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 */ }
}
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs