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] no rejection reason given for SFINAE
Date: Mon, 09 May 2011 14:07:00 -0000	[thread overview]
Message-ID: <bug-48934-4-D4aqO2LSbr@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48934-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-09 14:05:06 UTC ---
Another example:

  template<typename T> struct S1 { typedef char type; };

  template<typename T>
    typename S1<T>::type
    foo(typename S1<T>::typo)
    { return t; }

  char c = foo<int>(1);

Here the return type is valid, but the parameter is not ("typo" vs "type").
Ideally the diagnostic would indicate that, which would help when the template
arguments are substituted in more than one place.


My dream compiler would tell me exactly where it failed e.g.

  template<bool> struct S2 { typedef char type; };

  template<typename U> struct S3 { static const bool V = true; };

  template<typename T>
    typename S2<S3<T>::val>::type   // no 'val'
    foo(T t)
    { return t; }

  char c = foo(1);

This fails because "S3<T>::val" is an invalid expression ("val" vs "V")

My dream compiler would tell me which sub-expression was invalid, as this could
be a huge help when debugging complex SFINAE cases with nested expressions and
types.

I realise that might be very difficult to do and that as a library implementor
my wishlist may not be typical of most users. Simply saying something like
"substitution failed" would already be a nice improvement.


  parent reply	other threads:[~2011-05-09 14:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-09 11:48 [Bug c++/48934] New: " 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 [this message]
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-D4aqO2LSbr@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).