[Bug c++/48934] no rejection reason given for SFINAE

froydnj at codesourcery dot com gcc-bugzilla@gcc.gnu.org
Mon May 9 11:56:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48934

--- Comment #1 from froydnj at codesourcery dot com <froydnj at codesourcery dot com> 2011-05-09 11:53:58 UTC ---
On Mon, May 09, 2011 at 11:39:35AM +0000, redi at gcc dot gnu.org wrote:
> int foo(int);
> 
> template<typename T>
>   struct sfinae
>   { };
> 
> template<>
>   struct sfinae<float>
>   {
>       typedef double type;
>   };
> 
> template<typename T>
>   typename sfinae<T>::type
>   foo(T t)
>   { return t; }
> 
> struct Bar { };
> 
> Bar b = foo( Bar() );
> 
> 
> The error prints the two candidate functions and reason they weren't viable (I
> love this feature, thanks Nathan!)
> 
> reason.cc:20:20: error: no matching function for call to 'foo(Bar)'
> reason.cc:20:20: note: candidates are:
> reason.cc:1:5: note: int foo(int)
> reason.cc:1:5: note:   no known conversion for argument 1 from 'Bar' to 'int'
> reason.cc:15:10: note: template<class T> typename sfinae::type foo(T)
> 
> But no reason is given for the template.
> 
> I've only checked this with 4.6 so apologies if it's already been improved on
> trunk.

I submitted a patch for this:

http://gcc.gnu.org/ml/libstdc++/2011-02/msg00009.html

I need to clean it up a bit and possibly fix some testsuite failures.
Does that patch do what you want?



More information about the Gcc-bugs mailing list