Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/spaceship-eq11.C

raw
1 // PR c++/102490
2 // { dg-do run { target c++20 } }
3
4 struct A
5 {
6 unsigned char a : 1;
7 unsigned char b : 1;
8 constexpr bool operator== (const A &) const = default;
9 };
10
11 struct B
12 {
13 unsigned char a : 8;
14 int : 0;
15 unsigned char b : 7;
16 constexpr bool operator== (const B &) const = default;
17 };
18
19 struct C
20 {
21 unsigned char a : 3;
22 unsigned char b : 1;
23 constexpr bool operator== (const C &) const = default;
24 };
25
26 void
27 foo (C &x, int y)
28 {
29 x.b = y;
30 }
31
32 int
33 main ()
34 {
35 A a{}, b{};
36 B c{}, d{};
37 C e{}, f{};
38 a.b = 1;
39 d.b = 1;
40 foo (e, 0);
41 foo (f, 1);
42 return a == b || c == d || e == f;
43 }