public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/89997] Garbled expression in error message with -fconcepts
Date: Thu, 11 Nov 2021 23:02:56 +0000	[thread overview]
Message-ID: <bug-89997-4-wfk8nOOcN8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-89997-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89997

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
In GCC 10+ (with -fconcepts-diagnostics-depth=2), GCC produces:


<source>: In function 'void test()':
<source>:17:16: error: use of function 'void check() requires requires(X x, T
val) {x.X::operator<<()("hello") << val;} [with T = int]' with unsatisfied
constraints
   17 |     check<int>(); // mangled error
      |                ^
<source>:13:6: note: declared here
   13 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |      ^~~~~
<source>:13:6: note: constraints not satisfied
<source>: In instantiation of 'void check() requires requires(X x, T val)
{x.X::operator<<()("hello") << val;} [with T = int]':
<source>:17:16:   required from here
<source>:13:6:   required by the constraints of 'template<class T> void check()
requires requires(X x, T val) {x.X::operator<<()("hello") << val;}'
<source>:13:23:   in requirements with 'X x', 'T val' [with T = int]
<source>:13:60: note: the required expression '("hello"->x.X::operator<<() <<
val)' is invalid, because
   13 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |                                               ~~~~~~~~~~~~~^~~~~~
<source>:13:63: error: invalid conversion from 'int' to 'void*' [-fpermissive]
   13 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |                                                               ^~~
      |                                                               |
      |                                                               int
<source>:9:19: note:   initializing argument 1 of 'X Y::operator<<(void*)'
    9 |     X operator<< (void*);
      |                   ^~~~~

Is this good enoug now?


Note clang produces:
<source>:17:5: error: no matching function for call to 'check'
    check<int>(); // mangled error
    ^~~~~~~~~~
<source>:13:6: note: candidate template ignored: constraints not satisfied
[with T = int]
void check() requires requires (X x, T val) { x << "hello" << val; } {}
     ^
<source>:13:60: note: because 'x << "hello" << val' would be invalid: invalid
operands to binary expression ('Y' and 'int')
void check() requires requires (X x, T val) { x << "hello" << val; } {}
                                                           ^

       reply	other threads:[~2021-11-11 23:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
2021-11-11 23:02 ` pinskia at gcc dot gnu.org [this message]
2022-10-05  9:09 ` redi at gcc dot gnu.org
2022-10-05 12:46 ` redbeard0531 at gmail dot com
2022-10-05 13:42 ` redi at gcc dot gnu.org
2022-10-05 13:45 ` redi at gcc dot gnu.org
2022-10-05 15:00 ` redbeard0531 at gmail dot com

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-89997-4-wfk8nOOcN8@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).