[Bug c++/48934] New: no rejection reason given for SFINAE
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon May 9 11:48:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48934
Summary: no rejection reason given for SFINAE
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: redi@gcc.gnu.org
CC: froydnj@gcc.gnu.org
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 think the reason Clang++ gives is pretty good:
note: candidate template ignored: substitution failure [with T = Bar]
The key points to include in the reason are the template arguments and that
substitution failed (more formally, type deduction failed because substitution
resulted in an invalid type)
I've only checked this with 4.6 so apologies if it's already been improved on
trunk.
More information about the Gcc-bugs
mailing list