commit b064aafb08a8c85cfb84c839e21cf704adb42b2d Author: Jason Merrill Date: Sun May 22 22:18:07 2011 -0400 PR c++/49058 * call.c (splice_viable): Be strict in templates. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 972dca3..8503f5e 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3009,6 +3009,11 @@ splice_viable (struct z_candidate *cands, struct z_candidate **last_viable; struct z_candidate **cand; + /* Be strict inside templates, since build_over_call won't actually + do the conversions to get pedwarns. */ + if (processing_template_decl) + strict_p = true; + viable = NULL; last_viable = &viable; *any_viable_p = false; diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae24.C b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C new file mode 100644 index 0000000..3e1d2e7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae24.C @@ -0,0 +1,29 @@ +// PR c++/49058 +// This error is not subject to SFINAE because it doesn't happen in the +// deduction context. +// { dg-options -std=c++0x } +// { dg-prune-output "note" } + +template T val(); + +struct F1 +{ + void operator()(); +}; + +template +struct Bind +{ + template()( ) )> + R f(); + + template()( ) )> + R f() const; // { dg-error "no match" } +}; + +int main() +{ + Bind b; +}