Index: gcc/testsuite/g++.dg/cpp1y/auto-fn47.C =================================================================== --- gcc/testsuite/g++.dg/cpp1y/auto-fn47.C (nonexistent) +++ gcc/testsuite/g++.dg/cpp1y/auto-fn47.C (revision 257630) @@ -0,0 +1,6 @@ +// PR c++/84080 +// { dg-do compile { target c++14 } } + +template T foo(); + +template <> auto foo<0>() { return 42; } // { dg-error "does not match" } Index: gcc/cp/pt.c =================================================================== --- gcc/cp/pt.c (revision 257629) +++ gcc/cp/pt.c (revision 257630) @@ -2203,6 +2203,11 @@ specialize TMPL will produce DECL. */ continue; + if (uses_template_parms (targs)) + /* We deduced something involving 'auto', which isn't a valid + template argument. */ + continue; + /* Remove, from the set of candidates, all those functions whose constraints are not satisfied. */ if (flag_concepts && !constraints_satisfied_p (fn, targs))