<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88089>88089</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Diagnostics for P2266 (C++23) are poor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tiagomacarios
</td>
</tr>
</table>
<pre>
The diagnostics for the following code are very poor:
https://godbolt.org/z/5nv9dcr14
```c++
struct M {
M();
M(M&);
};
struct S {
int m1;
M m2;
};
S fun() {
S s{};
return s;
}
```
clang's output:
```
<source>:15:12: error: no viable conversion from 'S' to 'int'
15 | return s;
| ^
```
gcc's output:
```
<source>: In function 'S fun()':
<source>:15:12: error: use of deleted function 'S::S(S&&)'
15 | return s;
| ^
<source>:8:8: note: 'S::S(S&&)' is implicitly deleted because the default definition would be ill-formed:
8 | struct S {
| ^
<source>: At global scope:
<source>:8:8: error: cannot bind non-const lvalue reference of type 'M&' to an rvalue of type 'M'
<source>:5:7: note: initializing argument 1 of 'M::M(M&)'
5 | M(M&);
| ^~
<source>: In function 'S fun()':
<source>:15:12: note: use '-fdiagnostics-all-candidates' to display considered candidates
15 | return s;
| ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VV1vqzgQ_TXDyygVmM888JDbNtI-VFop-weMPRCvjB3ZJlXuw_72lUmakKi3u324FQ0wmMM5Z2Y83Hs1GKIWyh9QviR8Cnvr2qD4YEcuuFPWJ52Vp_avPaFUfDDWByU89tZh2BP2Vmv7rsyAwkpC7giP5E54sNZBvoH0BdLNPoSDj3dsC2w7WNlZHZ6sG4BtfwLblua4lsJlxXk5VOn5EMB-xGOO-uAmEfANob5E8A1YA2wN-UcAcY69AauWcahfbtdLsN0CDBGVCThm93A4si9wdthP5sziHmqHPt4vXohRR2FyBv0d4r3mJbrQ3AzAao92CocpXA19XJ0_ezs5QZC_Qr7JyvjDIN8gOTfnAY3Fo-KdJhTWHMl5ZQ32zo4IrN4BqzHYeKlMAFZfGWclQv2Mn3Kfo_NjKF-_UDEI8X0N-IeJ1ooQeUaKN6MjvyvIfyufPKHtUZKmQPIeNOLkmx2wZjeXTHWBP-v7f-IXfzcf7mk1l380NlA8f_FtVB7VeNBKqKBPV9odCR6VxJ6T1PNJh3hWRs1i3u2k4yJUWq9660aSV4-wmXl-XvJ3Gn7FHzcBB207rtELe6Bf2X_VeTVfcGNswE4ZicaalbDGB9RHridCRz05MmLOTzgdKPpy7t25HLlBd155_7z-9OMx9fXS5NjPKiiu1c-4P3E3TCOZgFmEm5HmDCw3jEXl4y35n20pj95B-frP7ynkDzkx-8DqVb_Yhldc65XgRirJA_mLb1L5g-an2OleSXIkcbHmobW_W9kfXZvINpfrfM0TarM6Y1XeFE2T7NuqL0XWd2kthFzzLi36TsiurwtiWbEWTaJalrIiLdJ1WpRF0TzljEous4LzSoqqIyhSGrnST1ofxzgmEuX9RG3TpM060bwj7eeJxZihd5wfAmNxgLk2vrPqpsFDkWrlg7-hBBU0tS8PU-xPxqoKgTXP52nD8riZx0EWZ1gyOd0-zC8V9lP3JOwIbBvBL6fVwdm_SQRg25mSB7adKf8bAAD__4Q4C0M">