https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114946
Bug ID: 114946
Summary: [concepts] No error for invalid requires constraint in
declaration
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nshead at gcc dot gnu.org
Target Milestone: ---
The following sample compiles fine with 'g++ -std=c++20 -pedantic-errors':
template <typename T>
requires xxxx
struct S {};
template <typename T>
requires xxxx
void foo() {}
Note that 'xxxx' has not been declared or defined. Both MSVC and Clang
complain about the undeclared identifier. GCC does error if we attempt to
instantiate either of these specialisations, but they always (silently) lose to
a better match:
template <typename T> struct S {};
template <typename T> requires xxxx struct S<T> {};
template <typename T> void foo() {}
template <typename T> requires xxxx void foo() {}
int main() {
S<int> x;
foo<int>();
}