[Bug c++/88378] New: notes for template deduction errors mention "[with U = U]"
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 5 18:36:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88378
Bug ID: 88378
Summary: notes for template deduction errors mention "[with U =
U]"
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
In error message like the one below where GCC fails to deduce the template
argument GCC includes notes that print things like "[with U = U]" -- i.e., the
template argument is the same as name of the parameter. It's only mildly
confusing in this small test case but in real world code with more template
parameters and where the names are much longer I suspect it makes the errors
quite a bit harder to decipher. I think just skipping the "[with U = U]" when
the deduction failed would be an improvement.
$ cat t.C && gcc -S -Wall t.C
template <class T>
struct S {
template <class U>
void f (U*&);
};
void g (S<int> s)
{
s.f (0);
}
t.C: In function ‘void g(S<int>)’:
t.C:9:9: error: no matching function for call to ‘S<int>::f(int)’
9 | s.f (0);
| ^
t.C:4:8: note: candidate: ‘template<class U> void S<T>::f(U*&) [with U = U; T =
int]’
4 | void f (U*&);
| ^
t.C:4:8: note: template argument deduction/substitution failed:
t.C:9:9: note: mismatched types ‘U*’ and ‘int’
9 | s.f (0);
| ^
For comparison, Clang prints just:
t.C:9:5: error: no matching member function for call to 'f'
s.f (0);
~~^
t.C:4:8: note: candidate template ignored: could not match 'U *' against 'int'
void f (U*&);
^
ICC prints:
t.C(9): error: no instance of function template "S<T>::f [with T=int]" matches
the argument list
argument types are: (int)
object type is: S<int>
s.f (0);
^
t.C(4): note: this candidate was rejected because at least one template
argument could not be deduced
void f (U*&);
^
and MSVC:
t.C(9): error C2672: 'S<int>::f': no matching overloaded function found
t.C(9): error C2784: 'void S<int>::f(U *&)': could not deduce template argument
for 'U *&' from 'int'
t.C(4): note: see declaration of 'S<int>::f'
More information about the Gcc-bugs
mailing list