gcc/testsuite/gcc.dg/field-merge-6.c
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O" } */ |
| 3 | /* { dg-shouldfail } */ |
| 4 | |
| 5 | /* Check that the third compare won't be pulled ahead of the second one and |
| 6 | prevent, which would prevent the NULL pointer dereference that should cause |
| 7 | the execution to fail. */ |
| 8 | |
| 9 | struct s { |
| 10 | char a, b; |
| 11 | int *p; |
| 12 | }; |
| 13 | |
| 14 | struct s a = { 0, 1, 0 }; |
| 15 | struct s b = { 0, 0, 0 }; |
| 16 | |
| 17 | int f () { |
| 18 | return (a.a != b.a |
| 19 | || *b.p != *a.p |
| 20 | || a.b != b.b); |
| 21 | } |
| 22 | |
| 23 | int main() { |
| 24 | f (); |
| 25 | return 0; |
| 26 | } |