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

            Bug ID: 124278
           Summary: Accepts conflicting scoped/unscoped enum redeclaration
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: suyuchang at whu dot edu.cn
  Target Milestone: ---

The code first declares a scoped enumeration (enum struct X0 {}) and then
redeclares it as an unscoped enum (enum X0;). This is ill-formed because a
scoped enum cannot be redeclared as unscoped. Clang rejects it, while GCC
accepts it.

Code:
enum struct X0 {} ; enum X0 ;

Command:
clang++ test.cpp

<source>:1:28: error: enumeration previously declared as scoped
    1 | enum struct X0 {}  ; enum  X0  ; 
      |                            ^
<source>:1:13: note: previous declaration is here
    1 | enum struct X0 {}  ; enum  X0  ; 
      |             ^
1 error generated.

See Compiler Explorer:https://godbolt.org/z/xbMeeMdKr

The test case was generated by a fuzzer.

Reply via email to