<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144280>144280</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang rejects templated consteval lambda within template
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dsacre
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVE2P5CYU_DX48jQWBn8efHD3pKNIOURR_gCGZzcrDF7Anuz--oi2e6ezOUZCAotXRVGvjAhBzxaxJ9WFVO-Z2OLd-V4FIT1mo1Pf-quzQSv0EO86wKpRIrgJpFNI-EDoY9T0GHJdCR0iLqsREYHwq7Yxz3PCfyF0kM6GiLswsDutYHKOsJawLjE0F0IHOCr-Xj2ILToYhQfC3-FQ9y-2BxA-GU8CAPAYN2-fGNZqGwkbYE31pLkAYcP6YC0Z4RcgzTvhB_Z1ydqkMWFG4U-Zj71U9HLjw4C_kjfSLas2GOBDxztcjbAzFC0IqwCFNxo9YVcQAT7QmMec6n69XnP4XUT0sKMP2tmQ_D3gs97xMB69d_6_hqc1vwa3eYnJFj5UhA-sJnz4AYFdeC1Gg0BYsxLWgBTWuggjgl5Wo6WO5htIscbNowJtQYARy6jEIdG65-abwklsJkJYUepJozpNr4A0V_g_9v_k6D3GNaT7shtht9mp0ZmYOz8TdvtO2E19__ql--NrJ4_yP3Fxu7YzpBA-Q0FqCpN3C8Q7Pi80YwyP7xRgiO7ZtbM1ymFqpN3Rx0SHOt7RJ9bPtNYUnH_l1DY6EGCdfXtGPz9k_QaLsGJGlU4adUAZj3Yq92HP0xcdocKmbkbVqKJWUk2yEKodORsF77qpqzulupJOVZNnqueq453IsC-ailJW1E2Z3ftCCM4byng3ohCc8g55RUVTFm1Z0q7KdM8oq2hdVKygTVXmVSsrRlVdtRXHrpxISXER2uTG7EtyOtMhbNgXZclamhkxogmPh4IxmdJJGEtvhu8T4G3c5kBKanSI4ZMi6miwP8Ls8QvK5P7pkXr5fV_ipu2Pimzzpv8pCTretzGXbiHslo45p7fVu0RP2O0hOxB2O5XvPfsnAAD__5Tgfxk">