<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/104413>104413</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C++23 default comparisons is incorrectly rejected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
marco-antognini-sonarsource
</td>
</tr>
</table>
<pre>
According to https://eel.is/c++draft/class.compare#default-1, the following C++23 program should compile.
```cpp
struct A {
bool operator ==(this A, A) = default;
};
int main() {
return A{}.operator ==(A{});
}
```
but Clang (18.1 and trunk) reports
```
<source>:2:20: error: defaulted member equality comparison operator must be const-qualified
2 | bool operator ==(this A, A) = default;
| ^
| const
<source>:2:8: error: invalid parameter type for defaulted equality comparison operator; found 'A', expected 'const A &'
2 | bool operator ==(this A, A) = default;
| ^ ~
2 errors generated.
```
FWIW, GCC accepts it.
Reproducible at https://godbolt.org/z/qM57nxz5d
See also https://stackoverflow.com/a/78808748/24103368 from @brevzin.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VM2S4yYQfpr2pcsqCaGRfNBBtkepHHJJDntG0LbJItAC8uzMIc-eQtLW_Gwyl1RUGEM3_fN9NC1C0FdL1EJ1hOq8E3O8Od-Owku3Fza6q9VW74Ozwgc3e0m7wanntpPSeaXtFaPDW4xTgLID1gPriUymA7BeAjsCOyovLjFtjQghk26chCdgpaKLmE3cF8BOGG-EF2eMe0o-T6slK3Hy7urFiOHmZqMwWWtDGeRnyLttfsjXIadplYToZxmxQ6iPuIoQB-cMuom8iM4jlOc0WBNvOmCXUuiAHZIct8SgPG4B6vPrepm1jTgKbYE1i1F9_BHFU5y9xS6J6nP2c7xNA-zwzv97JG9jDXPEkxH2isCaoskKFFZh9LP9mmJ7mpyP4R8J2bblab05KB-h7Fj65VB2SN47nxYbYFI40jiQR_o2C6PjM663pYOzr9SNc4g4EEpnQ9wvJy-a1A8GEBlCfcL_wjgu3-rlpw-qx4-nllT-FW3zDqy2d2G0wkl4MVIkj_F5SsXn3_DwGQFQHvHiZqsQWN0BqxMU-j6RTJbA6iWbVH3sIWnXXP8HUqB6xL9WHVvxBbySTa5JZZ-UVP_l1y8p1C-nEwopaYoBdXz3qH6nyTs1Sz0YQhE_PPGrU4MzMXP-Cqx_AdZ_-62q7feXSr118gcRChM-NogQhfzq7uQvxj2lhgCsF8D6umnypuYNsJ7xIi_LhwYv3o0IPB883V-0zXaqLdWhPIgdtUXNyjqvHw717tYymTeNqJUcGl7ISohDxXl54cVhkEoR3-mW5YznTVHlNS_KOruUBedU8UJyxqk4AM9pFNpkxtzHBG2nQ5ipLXLOi3JnxEAmLH2SMUtPuGiBsdQ2fZuM9sN8DcBzo0MMr26ijoba1562Xeyb2gqoA2ornfcko3lGT38u5bSbvWk_cK_jbR422lKM7W8_eZeMgPVLZqkDb6nfW_Z3AAAA__90dLzl">