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

            Bug ID: 121084
           Summary: [GCOV] Loops containing goto cause incorrect coverage
                    statistics.
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: njuwy at smail dot nju.edu.cn
  Target Milestone: ---

gcc version:
gcc version 16.0.0 20250704 (experimental) (GCC) 

option:
--coverage -std=c2x

$ cat test.c
int main(void) {
    int i = 0;
    while (i < 2) {
        ++i;
        if (i == 1) {
            goto loop_start;
        }
    loop_start:
        continue;
    }
    return 0;
}


$ cat test.c.gcov
        3:    1:int main(void) {
        1:    2:    int i = 0;
        3:    3:    while (i < 2) {
        2:    4:        ++i;
        2:    5:        if (i == 1) {
        1:    6:            goto loop_start;
        -:    7:        }
        1:    8:    loop_start:
        2:    9:        continue;
        -:   10:    }
        1:   11:    return 0;
        -:   12:}


cov of line 1 and line 8 should be 1 (main() was only executed once) and 2.
respectvely.

Reply via email to