Open
Description
Consider this piece of code:
template <int...>
consteval void foo()
{
constexpr auto bar = []<int...>() consteval {
return [](int* p) { *p = 42; };
};
(void) bar();
}
int main()
{
foo();
}
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 5e767bd.