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

            Bug ID: 123243
           Summary: Diagnostics for virtual functions with requires
                    clauses are not very user-friendly
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

Consider: 
https://godbolt.org/z/GxqffsePn

template<class T>
struct A {
  class B {
    virtual void f() requires true = 0;
  };
};

Clang gives
<source>:4:31: error: virtual function cannot have a requires clause
    4 |     virtual void f() requires true = 0;

MSVC gives
example.cpp
<source>(4): error C7632: 'A<T>::B::f': a trailing requires clause is not
allowed on a virtual function

However, GCC gives
<source>:4:38: error: lvalue required as left operand of assignment
[-Wtemplate-body]
    4 |     virtual void f() requires true = 0;

It would be great if GCC could explicitly state, like others, "that virtual
functions cannot have a requires clause"; the current diagnostic messages are
vague

Reply via email to