gcc/testsuite/g++.dg/opt/vrp2.C
raw| 1 | /* { dg-do run } */ |
| 2 | /* { dg-options "-O2" } */ |
| 3 | |
| 4 | /* VRP was miscompiling the following as it thought &a->b was a dereference |
| 5 | and therfore a was non-null. |
| 6 | Reduced from Mozilla by Serge Belyshev <[email protected]>. */ |
| 7 | |
| 8 | extern "C" void abort (void); |
| 9 | struct T { int i; } t; |
| 10 | struct A : T { int j; } *p = __null; |
| 11 | |
| 12 | int main (void) |
| 13 | { |
| 14 | if (p == &t) |
| 15 | return 0; |
| 16 | if (p) |
| 17 | abort (); |
| 18 | return 0; |
| 19 | } |
| 20 |