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

            Bug ID: 92523
           Summary: Unhelpful error messages when requires-clause contains
                    function call
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boostcpp at gmail dot com
  Target Milestone: ---

Following code produce unhelpful error messages:

constexpr bool f() { return true ; }

template < typename T >
    requires f()
void g(){}

https://wandbox.org/permlink/bH2Eo2aTC2JeueZt

prog.cc:4:14: error: constraint expression does not have type 'bool'
    4 |     requires f()
      |              ^
prog.cc:4:16: error: expected unqualified-id before ')' token
    4 |     requires f()
      |                ^

If the requires-clause was like this:

requires 2 + 2 == 5

It does produce helpful error messages which clearly show what's wrong here.

https://wandbox.org/permlink/xIMiqWVcVrDkMU55

prog.cc:4:14: error: constraint expression does not have type 'bool'
    4 |     requires 2 + 2 == 5
      |              ^
prog.cc:4:16: error: expression after 'requires' must be enclosed in
parentheses
    4 |     requires 2 + 2 == 5
      |              ~~^~~~~~~~
      |              (         )


function call expression inside the requires-clause should produce helpful
messages like it already does in other expressions.

Reply via email to