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

            Bug ID: 89997
           Summary: Garbled expression in error message with -fconcepts
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redbeard0531 at gmail dot com
  Target Milestone: ---

Usually -fconcepts delivers excellent error messages, but this one is pretty
bad. It looks like this goes back to 6.2, when it first started to show the
expression.

https://godbolt.org/z/m9DlOZ

struct Y;

struct X {
    Y operator<< (const char*);
};

struct Y {
    X operator<< (void*);
};

template <typename T>
void check() requires requires (X x, T val) { x << "hello" << val; } {}

void test() {
    check<int*>(); // no error
    check<int>(); // mangled error
}

-------------

<source>: In function 'void test()':
<source>:16:16: error: cannot call function 'void check() requires (<requires
(X x, T val) <valid-expression (x.X::operator<<()("hello") << val)>> [with T =
int]'
   16 |     check<int>(); // mangled error
      |                ^
<source>:12:6: note:   constraints not satisfied
   12 | void check() requires requires (X x, T val) { x << "hello" << val; } {}
      |      ^~~~~
<source>:12:6: note:     with 'X x'
<source>:12:6: note:     with 'int val'
<source>:12:6: note: the required expression '("hello"->x.X::operator<<() <<
val)' would be ill-formed


What is that expression? How did it end up applying -> to a string literal!?

Reply via email to