[llvm-bugs] [Bug 46059] New: [[gnu::used]] unsupported. Breaks many "inline static" use cases including P0424R0.
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun May 24 13:27:43 PDT 2020
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: unassignedclangbugs at nondot.org
Reporter: dsim at smallscript.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200524/d7f686fb/attachment-0001.html>
More information about the llvm-bugs
mailing list