the expressions in the for loop are not the compile-time constants so they are validated first at runtime. The compiler doesn't know whether the for loop are entered or not. If the for loop is not entered the continue statement is reacheable well.
If you change the for loop like this you will get unreacheable statement error:
Hi Let me try to explain this according to my understanding on the subject :
When we compile the program, Compiler do a flow analysis, in this flow analysis if its found any statement unreachable, it complains to us, this is unreachable code definition.
Now in the flow analysis compiler takes following into consideration :
It does not take condition expression result of While, for,Do expressions.
So in your case although the code is unreachable but from compilor point of view if inner for block never executes( as result of conditional expression doesnt come into consideration) then the continue statement becomes reachable.
The reason for this - from the compilers point of view - is that there could be any number of permutations possible in the loop, so it is unable to conclude whether the statement is unreachable in this case.
In more straight-forward cases it is able to advise, for example:
Hi Sunny Jain said the below quoted rules ,but when i use these rule on the code shown/given by Ian Edward then according to Sunny it should not be a compiler error but it gives unreachable error.
Sunny says:
When we compile the program, Compiler do a flow analysis, in this flow analysis if its found any statement unreachable, it complains to us, this is unreachable code definition.
Now in the flow analysis compiler takes following into consideration :