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

            Bug ID: 124308
           Summary: Accepts templated enum declaration
           Product: gcc
           Version: 16.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 attempts to declare an enum as a template: template <typename...> enum
X1;. Clang rejects the code, while GCC accepts it.

Code:
enum class X1 ;
template < typename ... > enum X1 ;

Command:
clang++ test.cpp

<source>:2:35: error: enumeration cannot be a template
    2 | template < typename ... > enum X1 ;
      |                                   ^
<source>:2:27: error: declaration does not declare anything
    2 | template < typename ... > enum X1 ;
      |                           ^
2 errors generated.

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

The test case was generated by a fuzzer.

Reply via email to