https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120332

--- Comment #1 from Wentao Zhang <wentaoz5 at illinois dot edu> ---
Another example affected by "no code", adapted from
https://sources.debian.org/src/procps/2%3A4.0.2-3/src/ps/display.c/#L636

"No code" version:

        1:    2:int main(void) {
        1:    3:    int i = 11;
        1:    4:    while (i--) {
       11:    5:        switch(i) {
branch  0 taken 4 (fallthrough)
branch  1 taken 7
        4:    6:        default:
        4:    7:            g++;
       12:    8:        case 1:
branch  0 taken 11
branch  1 taken 1 (fallthrough)
condition outcomes covered 2/2
        -:    9:        case 2:
        -:   10:        case 3:
        -:   11:        case 4:
        -:   12:        case 5:
        -:   13:        case 6:
        -:   14:        case 7:
        -:   15:            (void *) 0;
        -:   16:            // g++;
        -:   17:        }
        -:   18:    }
        -:   19:}

Normal version by uncommenting the 2nd "g++" statement:

        1:    2:int main(void) {
        1:    3:    int i = 11;
       12:    4:    while (i--) {
branch  0 taken 11
branch  1 taken 1 (fallthrough)
condition outcomes covered 2/2
       11:    5:        switch(i) {
branch  0 taken 4 (fallthrough)
branch  1 taken 7
        4:    6:        default:
        4:    7:            g++;
       11:    8:        case 1:
        -:    9:        case 2:
        -:   10:        case 3:
        -:   11:        case 4:
        -:   12:        case 5:
        -:   13:        case 6:
        -:   14:        case 7:
        -:   15:            (void *) 0;
       11:   16:            g++;
        -:   17:        }
        -:   18:    }
        -:   19:}

In the first version of "no code", line coverage, branch coverage and MC/DC
at line 8 for "case 1" label seem to all refer to loop predicate "i--".

Reply via email to