In both cases, the compiler considers both (a) what happens if the condition is false, and (b) what happens if it is true. As long as code is reachable by one of those two possibilities, then it's not considered unreachable.
Thanks Jim and Ben, from what i have understood from the above explanation i still have a doubt. In the below case is x = 7; still reachable? if it is reachable why not assign value 7 to variable x?
But if there's a possibility that a variable might be used without having been assigned first, that's an error.
here the variable is used without being assigned in line 1 not inside the if condition.
int x;
if (false) { // always false
x = 7; // reachable??
}
int y = x;//line 1
[ April 10, 2008: Message edited by: sridhar row ]