public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redbeard0531 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/89997] Garbled expression in error message with -fconcepts
Date: Wed, 05 Oct 2022 12:46:17 +0000	[thread overview]
Message-ID: <bug-89997-4-IjHfESXRBy@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 #3 from Mathias Stearn <redbeard0531 at gmail dot com> ---
Please reopen. It still seems to be broken with -std=c++20 as the only flag:
https://godbolt.org/z/bWMq4s6xb (trunk) https://godbolt.org/z/W3xWjWaGe (12.2)

Output:

<source>: In function 'void test()':
<source>:16:15: error: no matching function for call to 'check<int>()'
   16 |     check<int>(); // mangled error
      |     ~~~~~~~~~~^~
<source>:12:6: note: candidate: 'template<class T> void check() requires
requires(X x, T val) {x.X::operator<<(const char*)("hello") << val;}'
   12 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |      ^~~~~
<source>:12:6: note:   template argument deduction/substitution failed:
<source>:12:6: note: constraints not satisfied
<source>: In substitution of 'template<class T> void check() requires
requires(X x, T val) {x.X::operator<<(const char*)("hello") << val;} [with T =
int]':
<source>:16:15:   required from here
<source>:12:6:   required by the constraints of 'template<class T> void check()
requires requires(X x, T val) {x.X::operator<<(const char*)("hello") << val;}'
<source>:12:23:   in requirements with 'X x', 'T val' [with T = int]
<source>:12:60: note: the required expression '("hello"->x.X::operator<<() <<
val)' is invalid
   12 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |                                               ~~~~~~~~~~~~~^~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more
detail
Compiler returned: 1


The last line with <source> still says "the required expression
'("hello"->x.X::operator<<() << val)' is invalid". It should not be trying to
apply -> to a string literal. The following line with carrot and underline is
very helpful and shows what the problem is. But the "note" line seems actively
harmful since it is showing an expression that would never be valid for any
type. It seems like it would be better to remove that line than attempting to
show it if you can't reproduce the correct expression.

  parent reply	other threads:[~2022-10-05 12:46 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
2022-10-05  9:09 ` redi at gcc dot gnu.org
2022-10-05 12:46 ` redbeard0531 at gmail dot com [this message]
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-IjHfESXRBy@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).