public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105452] New: static_assert inside nameless nested union: invalid "inaccessible within this context" error
@ 2022-05-02 11:27 foobarandfoo at gmail dot com
  2022-05-03  8:39 ` [Bug c++/105452] " marxin at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: foobarandfoo at gmail dot com @ 2022-05-02 11:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105452

            Bug ID: 105452
           Summary: static_assert inside nameless nested union: invalid
                    "inaccessible within this context" error
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: foobarandfoo at gmail dot com
  Target Milestone: ---

template <typename T>
struct C {
  union {
    char v;
    static_assert(sizeof(v) == sizeof(char), "");
  };
};

int main() {
    C<int> x;
}

Fails to compile in every version I tried (including 13.0, 11.3.0, 11.2.0,
11.1.0, 10.3, 9.4) with "error: ‘char C<int>::<unnamed struct>::v’ is
inaccessible within this context static_assert(sizeof(v) == sizeof(char),
"");". If we modify struct C to be non-templated, the code compiles
successfully. Clang and MSVC compile the initial code.

https://godbolt.org/z/j171x1aGz

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

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 11:27 [Bug c++/105452] New: static_assert inside nameless nested union: invalid "inaccessible within this context" error foobarandfoo at gmail dot com
2022-05-03  8:39 ` [Bug c++/105452] " marxin at gcc dot gnu.org
2022-05-03  8:47 ` [Bug c++/105452] [9/10/11/12/13 Regression] static_assert inside anonymous union inside a templated struct causes " pinskia at gcc dot gnu.org
2022-05-03 13:17 ` ppalka at gcc dot gnu.org
2022-05-27  9:48 ` [Bug c++/105452] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
2022-07-26 11:37 ` rguenth at gcc dot gnu.org
2023-03-30  3:14 ` jason at gcc dot gnu.org
2023-03-30 22:26 ` cvs-commit at gcc dot gnu.org
2023-07-07 10:43 ` [Bug c++/105452] [11/12/13/14 " rguenth 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).