| Issue |
124497
|
| Summary |
[Clang] Wrong constraint evaluation for lambda in unevaluated context
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
MagentaTreehouse
|
The following should be valid C++20 code:
```c++
template <class T>
using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});
int main() {
F<int> f;
f(char{});
}
```
Clang rejects with:
```console
<source>:6:5: error: no matching function for call to object of type 'F<int>' (aka '(lambda at <source>:2:20)')
6 | f(char{});
| ^
<source>:2:20: note: candidate template ignored: constraints not satisfied [with a:auto = char]
2 | using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});
| ^
<source>:2:42: note: because 'sizeof(char) > sizeof a' (1 > 1) evaluated to false
2 | using F = decltype([] (auto a) requires (sizeof(T) > sizeof a) {});
| ^
```
Somehow it got `char` substituted into `T` in `sizeof(T)`?
See https://compiler-explorer.com/z/YvnzozWvx.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs