https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103239
Bug ID: 103239 Summary: confusing template argument deduction error message Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ich.freak at gmx dot net Target Milestone: --- When trying to resolve a function call, GCC iterates through the candidates, checking if it can deduce/substitute template parameters. When failing to deduce/substitute, it outputs nicely why it failed to do so. However, when 2 candidates fail for the same reason, it appears that this reason is only printed for the first candidate, not for the second one, leaving the user with a confusing message such as [...] note: template argument deduction/substitution failed: <source>:8:5: note: candidate: [...] that is, no reason is printed after the colon and, instead, the next candidate is listed. This seems surprising and unintended. It would be nice to tell the user why deduction/substitution failed for his/her favorite candidate. I drafted a small example here: https://godbolt.org/z/PjeGa3YPe The code is: #include <iostream> template<int> struct X { using T = int; template<class Y> using Z = Y::T; X() = default; template<class Y, class Q = Z<Y>> X(Y&& y, int, Q&& q = Q()) {} template<class Y, class Q = Z<Y>> X(Y&& y, int, Q&& q = Q(), int ignore = 10) {} }; int main () { const X<0> x = X<0>(); X<0> y(x, 0); }