<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86398>86398</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Deducing this Lambda ignores assignment rules for captured references
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Link1J
</td>
</tr>
</table>
<pre>
When using C++23 deducing this, captured references are assignable to anything.
The following code compiles with `clang -std=c++23`, when it clearly shouldn't. [Godbolt](https://godbolt.org/z/7TMoPK6an)
```c++
struct function {};
int main() {
function list;
[&list](this auto self) {
list = self;
}();
}
```
It even works with types that are not assignable. [Godbolt](https://godbolt.org/z/scazq7sfo)
```c++
struct function {
function& operator=(function const&) = delete;
};
int main() {
function list;
[&list](this auto self) {
list = self;
}();
}
```
And even it doesn't even need `self` as part of the assignment expression. [Godbolt](https://godbolt.org/z/8jxs4Pxbb)
```c++
struct function {
function& operator=(function const&) = delete;
};
int main() {
function list;
[&list](this auto self) {
list = function{};
}();
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkVEuP2zYQ_jWjy2ANibReBx3WK7homwI5BOiZEkcWE5pUyVF2N7--oLSPbFugSQ-9xDBg-JvhvL6ZT8VoLo6og_IEZZ-plWcfunfGfSp-yQavH7vfZ3K4RuMueAfiBOIkJGrS65ggnk0EcYejWngNpDHQRIHcSBFVINwTqMESskflHnk27nKAvIf89sNMOHlr_X0KNXpNOPrrYixFvDc8I1T5aJW74E1kDbIfnwuAKk9Z71NthnG0pIJ9xDj71WoHouYDQnn6yevBW4ayB9HMzEsEeQviDOJ82U0HHy4gzl9AnOsPv_n3v1bKgWj3-lKW7fuUd0cjh3VknFY3svEOoT5B3YN8MhvHeFXGgWhAtJt1wxHx9Y01kV9eJEuav6g2eCs2zRXVyh4j2elvgdInOSPIfvd4E6zu9-wvaELetrT__ZmRPpPDex8-Pc2cHxeKyLPijUDn-SsSv3-qcVRf_qjj5P_DVPeGniEQFfqFgmIfQKbcL86jd5FBVNucZI-aLDG96f5f6fk_uPl2Ym6d3pkxjNpT3HZ6RxyRTpexha5yVBEXFRj9hDw_X9yVHCM9LIFiNN59P2_Nx4d4fP8wDD8mby_Fvz3ub72uTHdSt7JVGXVFXRQiL5uyzeaupaqgvG2aVqpjlVeDKnUzFMUgazk2zZSZTuTimEshi2NZy_ZwrIthrHLVCKlLpSY45nRVxh6s_XxNhGUmxpW6ppJtk1k1kI3Pch665HQzrJcIxzw1F1-fsWG7Cf9dklgoe-y_VnV8p66DVmguzoek5q97Fdak0JMP_yT72Rps95ftMjyvw2H0VxDnlP_p52YJ_iONDOK89RDT3qU2_gwAAP__xL3wbQ">