<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61335>61335</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Unnamed bit field is being compared in defaulted equality operator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
foonathan
</td>
</tr>
</table>
<pre>
```cpp
#include <cassert>
#include <cstring>
struct foo
{
int member : 8;
int : 24;
bool operator==(const foo&) const = default;
};
int main()
{
// Create two objects with different object representations.
foo a, b;
std::memset(&a, 0xFF, sizeof(foo));
std::memset(&b, 0x99, sizeof(foo));
// Make all members identical to give them the same value representation.
a.member = 0;
b.member = 0;
// This does not pass?!
assert(a == b);
}
```
Demo: https://godbolt.org/z/75ee78Gss
Unnamed bit fields aren't members, so they shouldn't be compared.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVMGSpCgQ_Zr0kjEVFmhpHTz0tOue9rb7ASBpyS6CS2L39nz9hlrVNV0zEx1BAOaTx3tJgmK2F0_UQPkVyjZTSxpDbIYQvEqj8pkO5q2BU763fp4hbyF_AiGt791iCEE-94qZYgL5209RTtH6yx3dek5x6RMOIVyj1dd9gohofcKJJk0RQT5hDfIBXKOieA_fQR2CwzBTVClEkO3aRN0Hz_te4gTijPs3yBYNDWpx6c5UtQ-smxZlPYgaxPknYkF0IDp8jqQSYXoNGPTf1CfGV5tGNHYYKJJP1zBGmiMx-aSSDZ4Pd6YhBFQgnlF_MMzJgHwC-TTRxJQ2Iaftv_y_rltHtt8oDCDqzeJ5bZ8S6J3gfP6E4Aejf6h_CJVz1xNitIZ8sr1ymAJe7AthGmlaO2Q1Eb4ot9CD7ZtrdXg_5xbzD6r1r6Grkj9Hy2gCMfqQcFbMIDsQxxv3XpWiVrhXAuoPxqr2OrmV9_eGW5rCWmVjSjOv2du2vASjg0uHEC8gum8guqokqurfmb9f_Jf3aiKD2iYcLDnDqCJ5ENWtrnnLeliT9IY8hsWZHdaEfZhmFckcMtNIc5ZnlVFzPFV1UZelLLKxGWpdqKEsSR5NXp9FLwdVnOq6qKpTOdCQ2UbkQubymItjWZfFoc4rU-ZEg8qLoqwHKHKalHUH516m1U5mmRdqTkcpy8wpTY63R0EIT6-4gSDE-kbEZl3zRS8XhiJ3lhPfWZJNjpof_KNl1GT95d0cWn-7fGSQ_l2Us-nt_epmS3TNQ-5tGhd96MMEols3vA5f5hjWiwWi22QyiG6z8X8AAAD__2_-bs8">