]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/57043 (converting overloaded complex function pow in C++11 is ambiguous)
authorJason Merrill <jason@redhat.com>
Fri, 31 Jan 2014 15:20:05 +0000 (10:20 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 31 Jan 2014 15:20:05 +0000 (10:20 -0500)
PR c++/57043
* pt.c (fn_type_unification): Don't do DEDUCE_EXACT check
during partial ordering.

From-SVN: r207345

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/partial15.C [new file with mode: 0644]

index 49700e3b61bc425c7905c55c92f018a475e26d60..a9e56a472117de99cbc9d4c7e73242cb4db78791 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-31  Jason Merrill  <jason@redhat.com>
+
+       PR c++/57043
+       * pt.c (fn_type_unification): Don't do DEDUCE_EXACT check
+       during partial ordering.
+
 2014-01-31  Marek Polacek  <polacek@redhat.com>
 
        PR c/59963
index 981e2e0b2ed62c3159ae7202e04e757d0fd33369..ae5995b3f83c97b899d9ef5606e1ed643bf0ba96 100644 (file)
@@ -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 (file)
index 0000000..357bb05
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/57043
+// { dg-do link }
+
+template<typename D> struct complex { };
+
+template<typename Tp>
+complex<Tp>
+pow(const complex<Tp>& x, const complex<Tp>& y) { return complex<Tp>(); }
+
+template<typename T, typename U>
+struct promote_2 { typedef T type; };
+
+template<typename Tp, typename Up>
+complex<typename promote_2<Tp, Up>::type>
+pow(const complex<Tp>& x, const complex<Up>& y);
+
+complex<double> (*powcc)(const complex<double>&, const complex<double>&) = pow;
+
+int main() {}