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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-09
             Status|UNCONFIRMED                 |NEW
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=82334

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This seems like one specific case of PR 82334, which suggests that GCC should
tell you why each candidate doesn't match. So in this case it would tell you
that the candidate on line 2 is not a template. The error for line 6 should
also give some indication that it's referring to a function template, e.g.

<source>:6:6: error: no declaration matches 'template<int> void X::f()'

That would make it much more obvious that we're trying to match a template to a
non-template.

Clang is no better than GCC for this example, but EDG gets part of the way
there:

"t.C", line 6: error: "X" is not a class template
  void X::f()
       ^

It's true that X is not a class template, but that is only half the story. The
function template definition would match a member function template too:

struct X {
    template<int> void f();
};

template<int i>
void X::f()
{}

So it should really say X is not a class template and X::f is not a function
template.

Reply via email to