<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61105>61105</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang not diagnosing generic lambda with identifier in capture matching declarator-id of template parameter
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
accepts-invalid,
confirmed
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shafik
</td>
</tr>
</table>
<pre>
Given the following:
```cpp
void f() {
auto h = [y = 0]<typename y>(y) { return 0; };
}
```
clang should diagnose this since it is ill-formed, we can see this from [expr.prim.lambda.capture p5](https://eel.is/c++draft/expr.prim.lambda#capture-5) which says:
>If an identifier in a capture appears as the declarator-id of a parameter of the lambda-declarator's parameter-declaration-clause or as the name of a template parameter of the lambda-expression's template-parameter-list, the program is ill-formed.
and also has the following example:
```cpp
void f() {
int x = 0;
auto g = [x](int x) { return 0; }; // error: parameter and [capture](https://eel.is/c++draft/expr.prim.lambda#nt:capture) have the same name
auto h = [y = 0]<typename y>(y) { return 0; }; // error: template parameter and [capture](https://eel.is/c++draft/expr.prim.lambda#nt:capture)
// have the same name
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VF1zqzYQ_TXiZQcGSzbgBx7i-KbTn7FIC6gVEiMJJ_73HWF8neQmL23vjMfGYrUf55w9GIIeLFHLDid2OGe4xNH5NozY67-zzqlr-4e-kIU4EvTOGPeq7cDEEyvPrLx_V-XtI-f5dnJxWkHPeMP4EVh9up0C4BIdjMDEGdjhdF0fSnY4M_EcrzNZnAiuTPxgvLluV8FTXLyFkokTsPrMxJYtPX8s_74nadAOEEa3GAVK42BdIIijDhC0lQQ6gg6gjcl75ydSjD_DK4FEC4G2yN67KTVKb7MvZq-nwuDUKSwkznHxBPMhNc-bMcY5JFT4C-MvRKbQgfEXyfiJ8ZPy2Md0_ikN42JLlB_StK-jliMEvIbPAIsff_aAFrQiG3WvyYO2gHDvA-eZ0AfAsBKlSBr0GJ3PtQLXA8KMHieK5NPfFHNrIX-EMl6HR9jPF9rZXBpcAoHz9wIrUWveSNNsMNK3BdLQFIJ2di1wj88flYwOMaGfLs3eDR6nj9QU77FAqwBNcDBuvfxUJdAbTrOhf61ObSO8bZoUHzU73DX7diN8Df1eoQAANy0Aee88E0_vAEojsMNpI-8_KshGJp7uqfgRRrzQiktIHCWi_t_l-2q0L0TwO2fcBtq6-G7gX_0hU61QR3HEjNpdVdd1WVVVk42t7I-NUmVXy52QHHHX7JU8llTtsDuKssp0y0suSlHu-E7U-6bo9013rBpeVaKs606yfUkTalMYc5kK54dMh7BQW-125SEz2JEJq8dyvjoTE0-9dzaSVYxzxp8Z5yglzTHk2l7Q6Me5dLbXN4viyaN9m4rk3TIEti_T9oRH2aijofbmftbFu_Wl9RjIktdyW0x41XH8ZCh3O5kwyjFd-cVIvmA6W7xpP1I76DguXSHdxPhLam37yWfv_iKZWF7hSeyvCP0TAAD__9HuCE8">