Issue 156579
Summary [Clang][Regression:21] Rejects valid lambda invocation in constexpr if
Labels
Assignees
Reporter MagentaTreehouse
    The following C++20 code should be valid:
```c++
template <class>
auto f{[] (auto...) {
    if constexpr ([] (auto) { return true; }(0))
        return 0;
}};

int main() {
    f<int>();
}
```

Error since Clang 21:
```console
<source>:3:19: error: no matching function for call to object of type '(lambda at <source>:3:19)'
    3 |     if constexpr ([] (auto) { return true; }(0))
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:2:21: note: while substituting into a lambda _expression_ here
    2 | auto f{[] (auto...) {
      | ^
<source>:8:5: note: in instantiation of variable template specialization 'f' requested here
    8 |     f<int>();
      | ^
<source>:3:19: note: candidate template ignored: couldn't infer template argument 'auto:1'
    3 |     if constexpr ([] (auto) { return true; }(0))
 |    
```

See https://compiler-explorer.com/z/Kx5qWPev7.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to