https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99059
Bug ID: 99059
Summary: Static inline variable can't refer to itself
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent.hamp at higaski dot at
Target Milestone: ---
Declaring a static inline member variable and initializing it with a pointer to
itself is currently impossible. The textbook example for such code would
probably be a linked list of some sort:
struct link {
link* next{nullptr};
link* prev{nullptr};
};
struct list {
static inline link tail{&tail, &tail};
};
list l;
Making the member just static and initializing it outside of the class works,
but this kinda breaks my mental model of "static inline" as just being
syntactic sugar. Is this an actual bug or just some overlooked thing in the
standard?