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.

Reply via email to