public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/48934] New: no rejection reason given for SFINAE
Date: Mon, 09 May 2011 11:48:00 -0000	[thread overview]
Message-ID: <bug-48934-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2011-05-09 11:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-09 11:48 redi at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-48934-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).