<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141732>141732</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Failed to compile simple and legal code while gcc is ok
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yaoxinliu
</td>
</tr>
</table>
<pre>
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
>
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkV8uO47YS_ZryptCGRFqWvdDCz4uLLLJIZpFVQEklmRmK9JCUZ7oX-faAlNz29LgfQBIgPUMQkEjxUXXOYYklnJOtJiogW0O2nYjeH4wt7oX5IrWS_aQ09X3xCxHwFUK2Pnh_dMBXwPbA9q2pS6P81NgW2P4B2P5_n8qH3xqRLyDbAlu8fThbQrIKdZ6MNVl56o5KeAK-8fdH0qIj_BX4DpJVZXRFR4__dz__hMC3kKwQEQcvrsd_AL7Dymjn6SQU3oVmaYxCyNdoyfdWo6VPvbTkxr6x4eQDmQbY4gOwJYZ5KfA1Qr4dH9OzfWiOZIU3Flh0hG-ilWNjPTjmvPCy-l04R9YDWwTLgW-k9nHsZaDUHjsh9TA_2BT68-0TcICF2lYVSofmI7ANlr3HSgndYitP5JCsNdahcNgYpczngYlYB6z5DoFvnOltRcEKvuLAV_M8kB0nhxfXl85L33tpNErtzQCnFcFQ-nK05Fz4ZMn1ylONUqNAbfRdHCe-GjXuGgpHyDf4n2ZttBSjpZDt_rwqr-GnjY-H5vNBKsLqQNVHqVv0B0InvHSNqCKipkFNLuA2-tCR9vF96D2QpR8PNRmkFsUjxRmma3yuUPlBEPkHdfTdIsYX3y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