When compiling the follwing code, SDCC reports unreachable code for case 1, while the ASM file seems to be correct. Reproducable for at least mcs51 and stm8.
int test (int a)
{
switch (a) {
case 1:
break;
case 5:
return 1;
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
break;
}
return 0;
}
Add SDCC version: mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.8.0 #10562 (Linux)
Optimization has merged case 1 with cases 6-11, orphaning the break statement originally with case 1. Either the optimization needs to also remove the break statement or somehow mark it as unreachable due to optimization so that the warning can be suppressed.
I would like to hear the opinion of the other developers on this. IMO this issue can have low priority, but we should still try to fix this some day. Changing it to "won't fix" is saying that we think this is proper behaviour or that we don't care.
I'd keep it open. The bug itself is a bit funny anyway, since it affects only some ports (e.g. we get the warning on mcs51, but not z80).