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

            Bug ID: 121902
           Summary: Wrong coverage for control-flow change statement at
                    the end of an if statement
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: si1krow at outlook dot com
  Target Milestone: ---

Hit the issue when measuring coverage for the following Debian code: 
1. https://sources.debian.org/src/ifupdown/0.8.41/config.c#L597

How to reproduce it:

$ gcc --version
gcc (GCC) 16.0.0 20250907 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat > test.c << 'EOF'
void main() {
    for (int i = 0; i < 5; i++) {
        int arr[8];
        if (i == 0) {
            i = i;
            continue; 
        }
        continue;
        int j = 1;
    }
}
EOF

$ gcc --coverage test.c -o test
$ ./test
$ gcov test
$ cat test.c.gcov

...
        1:    1:void main() {
        6:    2:    for (int i = 0; i < 5; i++) {
        -:    3:        int arr[8];
        5:    4:        if (i == 0) {
        1:    5:            i = i;
        5:    6:            continue; 
        -:    7:        }
        4:    8:        continue;
        -:    9:        int j = 1;
        -:   10:    }
        1:   11:}
...

Line coverage at line 6 should not be 5 but 1.

Reply via email to