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

            Bug ID: 116099
           Summary: Inconsistent errors for ClassTemplate<NotDeclared> and
                    ClassTemplate<const NotDeclared>
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

template<class T> struct S { };

S<Oops> o;
S<const Oops> oo;


x.cc:3:3: error: 'Oops' was not declared in this scope
    3 | S<Oops> o;
      |   ^~~~
x.cc:3:7: error: template argument 1 is invalid
    3 | S<Oops> o;
      |       ^
x.cc:4:9: error: ISO C++ forbids declaration of 'type name' with no type
[-fpermissive]
    4 | S<const Oops> oo;
      |         ^~~~
x.cc:4:13: error: template argument 1 is invalid
    4 | S<const Oops> oo;
      |             ^



It would be nice to get the same error for both cases.

Aside: if I use -fpermissive it still won't compile (unsurprisingly):

x.cc:4:9: warning: ISO C++ forbids declaration of ‘type name’ with no type
[-fpermissive]
    4 | S<const Oops> oo;
      |         ^~~~
x.cc:4:13: error: template argument 1 is invalid
    4 | S<const Oops> oo;
      |             ^


Maybe a permerror here isn't useful?

Reply via email to