public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96116] New: GCC accepts "enum struct/class" in reference to enumeration
@ 2020-07-08 14:29 haoxintu at gmail dot com
  2020-07-08 14:35 ` [Bug c++/96116] " mpolacek at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: haoxintu at gmail dot com @ 2020-07-08 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96116
           Summary: GCC accepts "enum struct/class" in reference to
                    enumeration
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi,all.

This code, might be an invalid code, but GCC accepts it.

$cat test.cc
using alias1 = enum struct E1;
using alias2 = enum class E2;

While in clang:
$clang++ test.cc
test.cc:1:21: error: reference to enumeration must use 'enum' not 'enum struct'
[-Welaborated-enum-class]
using alias1 = enum struct E1;
                    ^~~~~~~
test.cc:2:21: error: reference to enumeration must use 'enum' not 'enum class'
[-Welaborated-enum-class]
using alias2 = enum class E2;
                    ^~~~~~
2 errors generated.


Here is a related bug report in llvm:
https://bugs.llvm.org/show_bug.cgi?id=46603

They suggested that ""enum class" can only be used when defining an enumeration
or as part of a standalone forward declaration"

Versions from 6.1 to trunk behave the same. So is this an invalid code for GCC?

Thanks,
Haoxin

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

* [Bug c++/96116] GCC accepts "enum struct/class" in reference to enumeration
  2020-07-08 14:29 [Bug c++/96116] New: GCC accepts "enum struct/class" in reference to enumeration haoxintu at gmail dot com
@ 2020-07-08 14:35 ` mpolacek at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-08 14:35 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-07-08

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2020-07-08 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 14:29 [Bug c++/96116] New: GCC accepts "enum struct/class" in reference to enumeration haoxintu at gmail dot com
2020-07-08 14:35 ` [Bug c++/96116] " mpolacek 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).