My GCC 9 patch for C++20 P0846R0 (ADL and function templates) tweaked cp_parser_template_name to only return an identifier if name lookup didn't find anything. In the deduce4.C case it means that we now return an OVERLOAD. That means that cp_parser_template_id will call lookup_template_function whereby producing a TEMPLATE_ID_EXPR with unknown_type_node. Previously, we created a TEMPLATE_ID_EXPR with no type, making it type-dependent. What we have now is no longer type-dependent. And so, when we call finish_call_expr after we've parsed "foo<int>(10)", even though we're in a template, we still do the normal processing, thus perform overload resolution. When adding the template candidate foo we need to deduce the template arguments, and that is where things go downhill. When fn_type_unification sees that we have explicit template arguments, but they aren't complete, it will use them to substitute the function type. So we substitute e.g. "void <T33d> (U)". But the explicit template argument was for a different parameter so we don't actually substitute anything. But the problem here was that we reduced the template level of 'U' anyway. So then when we're actually deducing the template arguments via type_unification_real, we fail in unify: 22932 if (TEMPLATE_TYPE_LEVEL (parm) 22933 != template_decl_level (tparm)) 22934 /* The PARM is not one we're trying to unify. Just check 22935 to see if it matches ARG. */ because 'parm' has been reduced but 'tparm' has not yet. Therefore we shouldn't reduce the template level of template parameters when tf_partial aka template argument deduction substitution. But we can only return after performing the cp_build_qualified_type etc. business otherwise things break horribly. 2020-03-03 Jason Merrill <jason@redhat.com> Marek Polacek <polacek@redhat.com> PR c++/90505 - mismatch in template argument deduction. * pt.c (tsubst): Don't reduce the template level of template parameters when tf_partial. * g++.dg/template/deduce4.C: New test. * g++.dg/template/deduce5.C: New test. * g++.dg/template/deduce6.C: New test. * g++.dg/template/deduce7.C: New test.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
ChangeLog | Loading commit data... | |
ChangeLog-1993 | Loading commit data... | |
ChangeLog-1994 | Loading commit data... | |
ChangeLog-1995 | Loading commit data... | |
ChangeLog-1996 | Loading commit data... | |
ChangeLog-1997 | Loading commit data... | |
ChangeLog-1998 | Loading commit data... | |
ChangeLog-1999 | Loading commit data... | |
ChangeLog-2000 | Loading commit data... | |
ChangeLog-2001 | Loading commit data... | |
ChangeLog-2002 | Loading commit data... | |
ChangeLog-2003 | Loading commit data... | |
ChangeLog-2004 | Loading commit data... | |
ChangeLog-2005 | Loading commit data... | |
ChangeLog-2006 | Loading commit data... | |
ChangeLog-2007 | Loading commit data... | |
ChangeLog-2008 | Loading commit data... | |
ChangeLog-2009 | Loading commit data... | |
ChangeLog-2010 | Loading commit data... | |
ChangeLog-2011 | Loading commit data... | |
ChangeLog-2012 | Loading commit data... | |
ChangeLog-2013 | Loading commit data... | |
ChangeLog-2014 | Loading commit data... | |
ChangeLog-2015 | Loading commit data... | |
ChangeLog-2016 | Loading commit data... | |
ChangeLog-2017 | Loading commit data... | |
ChangeLog-2018 | Loading commit data... | |
ChangeLog-2019 | Loading commit data... | |
ChangeLog.ptr | Loading commit data... | |
ChangeLog.tree-ssa | Loading commit data... | |
Make-lang.in | Loading commit data... | |
NEWS | Loading commit data... | |
call.c | Loading commit data... | |
cfns.gperf | Loading commit data... | |
cfns.h | Loading commit data... | |
class.c | Loading commit data... | |
config-lang.in | Loading commit data... | |
constexpr.c | Loading commit data... | |
constraint.cc | Loading commit data... | |
coroutines.cc | Loading commit data... | |
cp-gimplify.c | Loading commit data... | |
cp-lang.c | Loading commit data... | |
cp-name-hint.h | Loading commit data... | |
cp-objcp-common.c | Loading commit data... | |
cp-objcp-common.h | Loading commit data... | |
cp-tree.def | Loading commit data... | |
cp-tree.h | Loading commit data... | |
cp-ubsan.c | Loading commit data... | |
cvt.c | Loading commit data... | |
cxx-pretty-print.c | Loading commit data... | |
cxx-pretty-print.h | Loading commit data... | |
decl.c | Loading commit data... | |
decl.h | Loading commit data... | |
decl2.c | Loading commit data... | |
dump.c | Loading commit data... | |
error.c | Loading commit data... | |
except.c | Loading commit data... | |
expr.c | Loading commit data... | |
friend.c | Loading commit data... | |
g++spec.c | Loading commit data... | |
init.c | Loading commit data... | |
lambda.c | Loading commit data... | |
lang-specs.h | Loading commit data... | |
lex.c | Loading commit data... | |
logic.cc | Loading commit data... | |
mangle.c | Loading commit data... | |
method.c | Loading commit data... | |
name-lookup.c | Loading commit data... | |
name-lookup.h | Loading commit data... | |
operators.def | Loading commit data... | |
optimize.c | Loading commit data... | |
parser.c | Loading commit data... | |
parser.h | Loading commit data... | |
pt.c | Loading commit data... | |
ptree.c | Loading commit data... | |
rtti.c | Loading commit data... | |
search.c | Loading commit data... | |
semantics.c | Loading commit data... | |
tree.c | Loading commit data... | |
type-utils.h | Loading commit data... | |
typeck.c | Loading commit data... | |
typeck2.c | Loading commit data... | |
vtable-class-hierarchy.c | Loading commit data... |