public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97475] New: An unnamed class with a typedef name for linkage purposes having a method.
@ 2020-10-17 21:48 anders.granlund.0 at gmail dot com
  2021-08-04 11:20 ` [Bug c++/97475] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: anders.granlund.0 at gmail dot com @ 2020-10-17 21:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97475
           Summary: An unnamed class with a typedef name for linkage
                    purposes having a method.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anders.granlund.0 at gmail dot com
  Target Milestone: ---

Consider the following c++ program:

  typedef struct {
    void f();
  } X;

  int main()
  {
  }

It is not rejected by the compiler when compiling with "-std=c++20
-pedantic-errors".

The expected behaviour is that it should be rejected by section 9.2.3 paragraph
10 in the c++ 20 standard:

"
 10 An unnamed class with a typedef name for linkage purposes shall not
(10.1) — declare any members other than non-static data members, member
enumerations, or member classes,
(10.2) — have any base classes or default member initializers, or
(10.3) — contain a lambda-expression,
and all member classes shall also satisfy these requirements (recursively).
"

Note that clang correctly does reject the program:

  https://godbolt.org/z/rTerza

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

end of thread, other threads:[~2021-08-05 13:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-17 21:48 [Bug c++/97475] New: An unnamed class with a typedef name for linkage purposes having a method anders.granlund.0 at gmail dot com
2021-08-04 11:20 ` [Bug c++/97475] " redi at gcc dot gnu.org
2021-08-04 21:43 ` pinskia at gcc dot gnu.org
2021-08-05 11:32 ` redi at gcc dot gnu.org
2021-08-05 11:35 ` redi at gcc dot gnu.org
2021-08-05 13:34 ` anders.granlund.0 at gmail dot com

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).