1 /* 2 bug1717943c.c 3 an error in the detection of loopinvariants, 4 will move the foo=0 initialisation out of the loops. 5 */ 6 7 #include <testfwk.h> 8 9 char foo, firstcall; 10 check(void)11char check(void) 12 { 13 if(!firstcall) 14 return 1; 15 16 firstcall=0; 17 foo = 42; 18 return 0; 19 } 20 bug(void)21void bug(void) 22 { 23 while(1) { 24 foo = 0; 25 while(check()) 26 if(check()) 27 return; 28 } 29 } 30 31 32 void testBug(void)33testBug(void) 34 { 35 firstcall = 1; 36 bug(); 37 ASSERT(foo == 0); 38 } 39