Debian Codegraph @

gcc/testsuite/gdc.dg/torture/pr96435.d

raw
1 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96435
2 // { dg-do run }
3
4 @safe bool test96435()
5 {
6 int[2] array = [16, 678];
7 union U { int i; bool b; }
8 U u;
9 u.i = 0x81818181;
10 assert(array[u.b] == 678); // { dg-warning "accessing overlapped field" }
11 return u.b; // { dg-warning "accessing overlapped field" }
12 }
13
14 @safe void main()
15 {
16 auto b = test96435();
17 if (b)
18 assert(true);
19 if (!b)
20 assert(false);
21 }