https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125779
Bug ID: 125779
Summary: [c++] nested requirement check failure
Product: gcc
Version: 16.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marcel at laverdet dot com
Target Milestone: ---
// a.cc
template <class Type>
struct function_traits;
template <class Type>
requires requires { &Type::operator(); }
struct function_traits<Type> {};
template <class>
struct bind {
auto operator()() -> void requires false;
auto operator()() -> void requires true;
};
auto main() -> int {
function_traits<bind<int>> ft{};
return 0;
}
---
$ ~/gcc-16/bin/g++ -std=c++23 -c a.cc
a.cc: In function ‘int main()’:
a.cc:15:30: error: variable ‘function_traits<bind<int> > ft’ has initializer
but incomplete type
15 | function_traits<bind<int>> ft{};
| ^~
---
It works if you comment out the declaration which has `requires false`. clang &
msvc can handle it: https://godbolt.org/z/dKKGf1fac
Compiling from releases/gcc-16 @ 1997e95e4e