diff options
author | Jason Merrill <jason@redhat.com> | 2014-01-31 10:20:05 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2014-01-31 10:20:05 -0500 |
commit | 4b55a782a5c697bee6de69b694413437413a3c19 (patch) | |
tree | c7ac2e76483c14aba36089729ab0b3b99f98364d | |
parent | af3978a10db6f6b915b4a785228955d458062d2d (diff) | |
download | gcc-4b55a782a5c697bee6de69b694413437413a3c19.zip gcc-4b55a782a5c697bee6de69b694413437413a3c19.tar.gz gcc-4b55a782a5c697bee6de69b694413437413a3c19.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/partial15.C | 19 |
3 files changed, 30 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 49700e3..a9e56a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 981e2e0..ae5995b 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 0000000..357bb05 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial15.C @@ -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() {} |