“Impossible” here means “should not happen”, and not literally “cannot happen”, which, obviously, it makes no sense to check for the latter. In other words, you think that you wrote your code so that the variable could only have values at a certain point 1, 2or 3, and you write your statements ifto process them, but then add a final sentence elsethat will do something to attract your attention, so if you make a mistake and your code is not as waterproof as you thought, then you can see, and the error won’t just avoid your attention.
For example:
if ( val == 1 ) {
} else if ( val == 2 ) {
} else if ( val == 3 ) {
} else {
printf("ERROR - val has an unexpected value!\n");
exit(EXIT_FAILURE);
}
source
share