1/* { dg-do run } */ 2/* { dg-options "-O2" } */ 3 4extern void abort (void) __attribute__ ((__nothrow__)) __attribute__ 5((__noreturn__)); 6extern void exit (int __status) __attribute__ ((__nothrow__)) 7__attribute__ ((__noreturn__)); 8int useboot (void *); 9 10struct bootLoader { 11 int x; 12}; 13 14void 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 29int 30useboot (void *boot) 31{ 32 abort (); 33} 34 35int 36main() 37{ 38 zap (0); 39 return 0; 40} 41