Issue 141732
Summary [clang] Failed to compile simple and legal code while gcc is ok
Labels clang
Assignees
Reporter yaoxinliu
    See: [https://godbolt.org/z/GqbzYfa78](https://godbolt.org/z/GqbzYfa78)

```
template<typename T>
concept IsOK =
    []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();

static_assert(IsOK<int>);

int main() {
}
```
**gcc is ok, but clang gives errors as follows:**

> <source>:3:67: error: substitution into constraint _expression_ resulted in a non-constant _expression_
>     3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^~~~~~~~~~~~~
> <source>:3:67: note: while checking the satisfaction of nested requirement requested here
>     3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^~~~~~~~~~~~~
> <source>:3:67: note: in instantiation of requirement here
> 3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^~~~~~~~~~~~~
> <source>:3:67: note: while checking the satisfaction of nested requirement requested here
> 3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^~~~~~~~~~~~~
> <source>:3:38: note: while substituting into a lambda _expression_ here
>     3 | []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^
> <source>:3:5: note: while substituting template arguments into constraint _expression_ here
>     3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> <source>:5:15: note: while checking the satisfaction of concept 'IsOK<int>' requested here
>     5 | static_assert(IsOK<int>);
>       | ^~~~~~~~~
> <source>:3:67: note: subexpression not valid in a constant _expression_
>     3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       | ^
> <source>:5:15: error: static assertion failed
>     5 | static_assert(IsOK<int>);
> |               ^~~~~~~~~
> <source>:5:15: note: because 'int' does not satisfy 'IsOK'
> <source>:3:5: note: because '[]<typename U>() -> bool {
> return requires { requires <<error-_expression_>>; };
> }.template operator()<int>()' evaluated to false
>     3 |     []<typename U> consteval -> bool { return requires { requires sizeof(U) > 1; }; }.template operator()<T>();
>       |     ^
> 2 errors generated.
> Compiler returned: 1
> 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to