gcc/testsuite/gcc.dg/torture/pr47365.c
raw| 1 | /* { dg-do run } */ |
| 2 | |
| 3 | struct A |
| 4 | { |
| 5 | int i; |
| 6 | }; |
| 7 | |
| 8 | struct B |
| 9 | { |
| 10 | struct A a[2]; |
| 11 | }; |
| 12 | |
| 13 | int i = 1; |
| 14 | struct B b = { 0, 3 }; |
| 15 | |
| 16 | static void |
| 17 | test () |
| 18 | { |
| 19 | if (b.a[0].i != i) |
| 20 | { |
| 21 | int t = b.a[0].i; |
| 22 | b.a[0] = b.a[1]; |
| 23 | b.a[1].i = t; |
| 24 | } |
| 25 | |
| 26 | if (b.a[1].i == i) |
| 27 | __builtin_abort (); |
| 28 | |
| 29 | if (b.a[0].i == 0) |
| 30 | __builtin_abort (); |
| 31 | } |
| 32 | |
| 33 | int |
| 34 | main () |
| 35 | { |
| 36 | test (); |
| 37 | return 0; |
| 38 | } |
| 39 |