Menu

#2843 Incorrect warning message about unreachable code

open
nobody
None
MCS51
2
2022-07-13
2018-11-27
No

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;
}

Discussion

  • 笑行天下

    笑行天下 - 2018-11-27

    Add SDCC version: mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.8.0 #10562 (Linux)

     
  • Erik Petrich

    Erik Petrich - 2019-03-29

    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.

     
  • Sergey Belyashov

    • status: open --> closed-wont-fix
     
    • Maarten Brock

      Maarten Brock - 2020-08-18

      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.

       
      • Philipp Klaus Krause

        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).

         
  • Maarten Brock

    Maarten Brock - 2022-07-13
    • status: closed-wont-fix --> open
    • Category: other --> MCS51
    • Priority: 5 --> 2
     

Log in to post a comment.

MongoDB Logo MongoDB