public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-11 23:02 UTC (permalink / raw)
  To: gcc-bugs

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; } {}
                                                           ^

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

* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
  2021-11-11 23:02 ` [Bug c++/89997] Garbled expression in error message with -fconcepts 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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-05  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Is this good enoug now?

I'm going to assume the answer's yes.

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

* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
  2021-11-11 23:02 ` [Bug c++/89997] Garbled expression in error message with -fconcepts 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
  2022-10-05 13:42 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: redbeard0531 at gmail dot com @ 2022-10-05 12:46 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-05 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |---
     Ever confirmed|0                           |1
             Status|RESOLVED                    |NEW
   Last reconfirmed|                            |2022-10-05

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
N.B. the reporter can reopen the bug themselves (which is sometimes annoying
:-)

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

* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-05 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=49152

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think this is probably not concepts-specific, and just another variant of PR
49152.

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

* [Bug c++/89997] Garbled expression in error message with -fconcepts
       [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-10-05 13:45 ` redi at gcc dot gnu.org
@ 2022-10-05 15:00 ` redbeard0531 at gmail dot com
  5 siblings, 0 replies; 6+ messages in thread
From: redbeard0531 at gmail dot com @ 2022-10-05 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Mathias Stearn <redbeard0531 at gmail dot com> ---
> I think this is probably not concepts-specific, and just another variant of PR 49152.

Perhaps the busted pretty printer is a general problem, but at least in this
case I think the fix may be in concepts code. It looks like the error is
generated at
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/cp/constraint.cc#L3300
(or the similar call 7 lines lower). Given that gcc already prints the source
loc with the invalid expression, I think you can just remove the %qE to improve
the diagnostic output. (I don't know the gcc codebase at all, so I could be
wrong about this, I just grepped for the string "the required expression")

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

end of thread, other threads:[~2022-10-05 15:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-89997-4@http.gcc.gnu.org/bugzilla/>
2021-11-11 23:02 ` [Bug c++/89997] Garbled expression in error message with -fconcepts 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
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

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).