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

            Bug ID: 96379
           Summary: [ 10/11 Regression ] GCC accepts totally invalid
                    template declaration
           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.

Input:
//small.cc
const int a = 0;
const long b = 1 ;
enum struct c;
template <class> enum struct c : union enum class c { e = b, f = a }; 
enum class c {};

Output (GCC-10.1):
<source>:4:23: warning: elaborated-type-specifier for a scoped enum must not
use the 'struct' keyword
    4 | template <class> enum struct c : union enum class c { e = b, f = a };
      |                  ~~~~ ^~~~~~
      |                       ------
<source>:4:32: error: expected unqualified-id before ':' token
    4 | template <class> enum struct c : union enum class c { e = b, f = a };
      |                                ^
<source>:5:12: error: multiple definition of 'enum class c'
    5 | enum class c {};
      |            ^
<source>:4:51: note: previous definition here
    4 | template <class> enum struct c : union enum class c { e = b, f = a };
      |    

GCC-trunk and GCC-10.2 accept this code, while GCC-10.1 downwards versions
reject this. I am sure the code is totally invalid, so I guess there might be
something wrong with GCC-trunk.

Reproduced in Godbolt : https://godbolt.org/z/jTejTT

Thanks,
Haoxin

Reply via email to