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

            Bug ID: 129243
           Summary: Improve diagnosis for virtual function with requires
                    clause
           Product: gcc
           Version: 16.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:

template<class T>
concept C = true;

template<class T>
struct S {
  class A {
    virtual int f() requires C<T> = 0;
  };
};


Clang gives:

<source>:7:30: error: virtual function cannot have a requires clause
    7 |     virtual int f() requires C<T> = 0;
      |  

MSVC gives:

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

However, GCC gives:

<source>:7:30: error: lvalue required as left operand of assignment
[-Wtemplate-body]
    7 |     virtual int f() requires C<T> = 0;
      |

Reply via email to