<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116961>116961</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] False positive unused private field if defaulted member comparison operator declared out-of-class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics,
false-positive
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Maetveis
</td>
</tr>
</table>
<pre>
Observed:
```c++
class A {
int used;
bool operator==(const A&) const;
};
bool A::operator==(const A&) const = default;
class B {
int used;
friend bool operator==(const B&, const B&);
};
bool operator==(const B&, const B&) = default;
```
`clang++ -std=c++20 -Wunused-private-field test.cpp`
[Compiler explorer link](https://godbolt.org/z/GnE3fdc45)
```plaintext
<source>:2:7: warning: private field 'used' is not used [-Wunused-private-field]
2 | int used;
| ^
1 warning generated.
Compiler returned: 0
```
Exptected:
No warnings.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEFv8zYM_TX0hXBgU3HcHHxwkmanbcedZYl2tSmWIclZt18_yHbarii6fQERSyT09MhHSoZghpG5geoE1SWTc3xxvvlZcryzCVnn9F_Nr11gf2cNooXiAkULh2I1BXRKtniVlSFgi1BvDkQzRpxDOvnm6pyz6Cb2MjoP4pKMnpQbQ8QW6AB0xGX3dgbqy_t6-V8w2kRHtP8HCkFcUHMvZxs_Qa2kT9-T7r3hUX9L_bTcd8aPu-N_pfAjWF_n8BDiI3TSxcpxWLXBPEQN4rJJRQXmv81jyi-fvLnLyHlv2GqMHOJOTdNntOp0drfJWPbIr5N1nj1aM_4BVWL8EuMUkhJ0BboOTnfOxp3zA9D1b6DrT-Oz6LXaV6kc_ya52mSlGSO_xs0vzsHNXjGIZxAtgWhrEC3-Kf1oxiEtN9q40gaqF7GoRhNwdKt2CNXp6zwT7U1oREKoz191afql0LaqntdA-eCBA49JO9a7NfJWI89x9uMyLFh8o9Lz6xRZxQ9T9Yt7oIcNNNON0EdxlBk3ZS2oLKqK6uylUd1Tr0nJojwoEjV3RSWPRE9dr1RfaspMQwXty5KKkqiieif2opLq2JV90VMnJewLvkljd9beb0mvzIQwc1OWh-OhzKzs2IblVSBau0m02shhdCEaFYAI6AxEvbSB88kFE82dk7u6ZL5JqHk3DwH2hTUhhvd7ool2eW_OC2x1wWvCwAcGrqp9ktn0j-ZnjTe-dexRudskvQlufJsk1Kys9KzRzTF3fb7MdzZ723zqVBNf5m6n3A3omrhtn3zy7ndWEei6FCQAXbea3Bv6JwAA__9f9Iih">