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

            Bug ID: 66941
           Summary: Missing diagnostic "extraneous template parameter list
                    in template specialization"
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: miyuki at gcc dot gnu.org
  Target Milestone: ---

Consider this testcase:

$cat genpreds1_min.cc
template <typename>
class A;

template <int>
struct B;

template <typename>
struct C;

template <>
template <int N>
struct C <B <N> >
{
    template<typename T>
    A <B <N> >
    m_fn(T);
};

template <int N>
template <typename T>
A <B <N> >
C <B <N> >::m_fn (T)
{
}

EDG rejects it with the following error:
/opt/intel/bin/icpc -c genpreds1_min.cc 
genpreds1_min.cc(22): error: incomplete type is not allowed
  C <B <N> >::m_fn (T)
  ^

genpreds1_min.cc(22): error: template argument list must match the parameter
list
  C <B <N> >::m_fn (T)
  ^

compilation aborted for genpreds1_min.cc (code 2)

Clang gives warning:
/opt/clang-trunk/bin/clang++ -c genpreds1_min.cc 
genpreds1_min.cc:10:1: warning: extraneous template parameter list in template
specialization
template <>
^~~~~~~~~~~
1 warning generated.

But GCC silently accepts this code. I suppose that GCC could warn about:
template <typename>
struct base {};

template <typename>
struct s {};

template <>
template <typename T>
struct base <s <T> > {};

like Clang does (note: in this case EDG accepts the code without
warnings/errors).

Reply via email to