https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120975
Bug ID: 120975 Summary: GCC incorrectly accepts requires-clause for virtual functions Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ykakeyama3014 at gmail dot com Target Milestone: --- GCC seems to accept incorrect code like below: template <typename T> struct A { virtual void f() requires true; }; C++ standard explicitly forbids constraints for virtual functions as per [class.virtual]#6. Additionally, GCC also accepts: template <typename T> struct A { virtual void f() requires true final; }; This is syntactically not allowed, as member-declarator and function-definition cannot have both virt-specifier-seq and requires-clause; see [class.mem.general] and [dcl.fct.def.general]. references: https://eel.is/c++draft/class.virtual#6 https://eel.is/c++draft/class.mem.general#nt:member-declarator https://eel.is/c++draft/dcl.fct.def.general#nt:function-definition