janhaag/PSE2011 — Issue #109: Division / modulo by zero and array access in while condition
Author: ratefuchs
Created: 2012-03-07 12:03:35+00:00
State: open
Labels: Parser

Consider the following program:

main(){
int y=1;
while(y/y==1){ y=0; }
}

The implicit statement only prevents y from being zero the first time the loop is entered. There is no check after executing the loop once or more, so checking the condition a second time will lead to a division by zero (which is defined as 0, so the loop will terminate in this program).