public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48934] New: no rejection reason given for SFINAE
@ 2011-05-09 11:48 redi at gcc dot gnu.org
  2011-05-09 11:56 ` [Bug c++/48934] " froydnj at codesourcery dot com
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-09 11:48 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-07-17 16:38 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-09 11:48 [Bug c++/48934] New: no rejection reason given for SFINAE redi at gcc dot gnu.org
2011-05-09 11:56 ` [Bug c++/48934] " froydnj at codesourcery dot com
2011-05-09 12:05 ` redi at gcc dot gnu.org
2011-05-09 12:24 ` redi at gcc dot gnu.org
2011-05-09 14:07 ` redi at gcc dot gnu.org
2011-05-09 15:49 ` froydnj at codesourcery dot com
2011-05-09 16:15 ` froydnj at codesourcery dot com
2011-05-09 16:30 ` redi at gcc dot gnu.org
2011-05-09 16:34 ` redi at gcc dot gnu.org
2011-05-09 17:14 ` froydnj at gcc dot gnu.org
2011-05-09 18:26 ` jason at gcc dot gnu.org
2011-05-09 19:17 ` redi at gcc dot gnu.org
2011-05-09 19:20 ` redi at gcc dot gnu.org
2011-05-09 19:23 ` froydnj at codesourcery dot com
2011-05-09 19:27 ` froydnj at codesourcery dot com
2011-05-09 20:14 ` jason at gcc dot gnu.org
2011-07-17  2:35 ` jason at gcc dot gnu.org
2011-07-17 12:58 ` jason at gcc dot gnu.org
2011-07-17 16:38 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).