int getValue( int x, int y, int z )
{
if( x != 0 )
y = 5;
/* dead code from here */
else // x == 0
z = z-x ; // by constant folding, z = z-0 ; => dead code
/* till here */
/* getValue results in undefined behaviour if z > 1, and x ==0 */
if( z > 1 )
z = z/x ; // will lead to undefined behaviour if x==0
else // z < 2
z = y;
return z;
}
The invariant on entry is therefore:
1 2 3 4
if( x==0 ) z must be less than or equal to 1
if( x!= 0 ) a. z may be less than or equal to 1
b. z may be greater than 1