public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99059] New: Static inline variable can't refer to itself
@ 2021-02-10 14:17 vincent.hamp at higaski dot at
  2021-02-10 22:21 ` [Bug c++/99059] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincent.hamp at higaski dot at @ 2021-02-10 14:17 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-09  3:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 14:17 [Bug c++/99059] New: Static inline variable can't refer to itself vincent.hamp at higaski dot at
2021-02-10 22:21 ` [Bug c++/99059] " redi at gcc dot gnu.org
2021-02-10 22:22 ` redi at gcc dot gnu.org
2021-02-21  0:39 ` ldalessandro at gmail dot com
2021-12-09  2:57 ` adrianh.bsc at gmail dot com
2021-12-09  3:06 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).