https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112749
Bug ID: 112749 Summary: GCC accepts invalid code in concepts (requires clause incorrectly satisfied) Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: novulae at hotmail dot com Target Milestone: --- The below example is ill-formed - the requires clause should not be satisfied due to the failure to instantiate W1<int>, but GCC accepts the code nonetheless. Clang rejects the code. $ cat gcc-bug.cpp template<class> concept C1 = true; template<class T> using W1 = decltype(nonexistent<T>(0)); template<class T> requires C1<W1<T>> void func(T); void test() { func(0); } $ g++ -c -std=c++20 gcc-bug.cpp $ clang++ -c -std=c++20 gcc-bug.cpp gcc-bug.cpp:10:3: error: no matching function for call to 'func' 10 | func(0); | ^~~~ gcc-bug.cpp:7:6: note: candidate template ignored: constraints not satisfied [with T = int] 7 | void func(T); | ^ gcc-bug.cpp:3:39: note: because substituted constraint expression is ill-formed: use of undeclared identifier 'nonexistent' 3 | template<class T> using W1 = decltype(nonexistent<T>(0)); | ^ 1 error generated.