1 /* { dg-do run } */ 2 /* { dg-options "-O2" } */ 3 4 extern void abort (void) __attribute__ ((__nothrow__)) __attribute__ 5 ((__noreturn__)); 6 extern void exit (int __status) __attribute__ ((__nothrow__)) 7 __attribute__ ((__noreturn__)); 8 int useboot (void *); 9 10 struct bootLoader { 11 int x; 12 }; 13 14 void zap(struct bootLoader * bootLoader)15zap(struct bootLoader *bootLoader) 16 { 17 /* The expression on the RHS of the assignment is *not* a 18 dereference of pointer 'bootLoader'. It is merely used as an 19 offset calculation. VRP was erroneously removing the if() 20 because it thought that 'bootLoader' was always dereferenced. */ 21 int *boot = &bootLoader->x; 22 23 if (bootLoader) 24 { 25 useboot (boot); 26 } 27 } 28 29 int useboot(void * boot)30useboot (void *boot) 31 { 32 abort (); 33 } 34 35 int main()36main() 37 { 38 zap (0); 39 return 0; 40 } 41