From: Jason Merrill Date: Fri, 31 Jan 2014 15:20:05 +0000 (-0500) Subject: re PR c++/57043 (converting overloaded complex function pow in C++11 is ambiguous) X-Git-Tag: releases/gcc-4.9.0~1190 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b55a782a5c697bee6de69b694413437413a3c19;p=thirdparty%2Fgcc.git re PR c++/57043 (converting overloaded complex function pow in C++11 is ambiguous) PR c++/57043 * pt.c (fn_type_unification): Don't do DEDUCE_EXACT check during partial ordering. From-SVN: r207345 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49700e3b61bc..a9e56a472117 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-01-31 Jason Merrill + + PR c++/57043 + * pt.c (fn_type_unification): Don't do DEDUCE_EXACT check + during partial ordering. + 2014-01-31 Marek Polacek PR c/59963 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 981e2e0b2ed6..ae5995b3f83c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -15740,8 +15740,11 @@ fn_type_unification (tree fn, /* If we're looking for an exact match, check that what we got is indeed an exact match. It might not be if some template - parameters are used in non-deduced contexts. */ - if (strict == DEDUCE_EXACT) + parameters are used in non-deduced contexts. But don't check + for an exact match if we have dependent template arguments; + in that case we're doing partial ordering, and we already know + that we have two candidates that will provide the actual type. */ + if (strict == DEDUCE_EXACT && !any_dependent_template_arguments_p (targs)) { tree substed = TREE_TYPE (decl); unsigned int i; diff --git a/gcc/testsuite/g++.dg/template/partial15.C b/gcc/testsuite/g++.dg/template/partial15.C new file mode 100644 index 000000000000..357bb05fa3b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial15.C @@ -0,0 +1,19 @@ +// PR c++/57043 +// { dg-do link } + +template struct complex { }; + +template +complex +pow(const complex& x, const complex& y) { return complex(); } + +template +struct promote_2 { typedef T type; }; + +template +complex::type> +pow(const complex& x, const complex& y); + +complex (*powcc)(const complex&, const complex&) = pow; + +int main() {}