Issue 144280
Summary Clang rejects templated consteval lambda within template
Labels clang
Assignees
Reporter dsacre
    Consider this piece of code:

```cpp
template <int...>
consteval void foo()
{
 constexpr auto bar = []<int...>() consteval {
    return [](int* p) { *p = 42; };
  };
  (void) bar();
}
```

This compiles with Clang 18 and earlier, as well as with GCC. Later versions of Clang give this error:

```
<source>:5:26: error: variable 'p' cannot be implicitly captured in a lambda with no capture-default specified
    5 |     return [](int* p) { *p = 42; };
```

https://godbolt.org/z/dzqj9Pq9c

Removing `consteval` from the lambda gets the code to compile, as does converting either `foo()` or the lambda into a non-template.

I managed to bisect this down to commit 5e767bd7d16dcdfc1ad8b32ba399f969dd940f57.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to