https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128557
Bug ID: 128557
Summary: [GCOV] unreachable "continue;" statement after
"break;" is wrongly marked as executed
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: iamanonymous.cs at gmail dot com
Target Milestone: ---
This appears to be a regression of PR gcov-profile/85217, which was
previously closed as fixed but whose symptom reappears on current trunk.
Filed as a new report per the developer's request.
See also PR gcov-profile/85217.
$ gcc --version
gcc (GCC) 17.0.0 20261101 (experimental)
$ cat small.c
int a=0;
void main() {
for (;; a++) {
int c[1];
if (a) {
break;
a;
continue;
}
continue;
}
}
$ gcc -w --coverage small.c && ./a.out && gcov small.c
Actual (buggy) output:
2: 3:void main() {
2: 4: for (;; a++) {
-: 5: int c[1];
2: 6: if (a) {
1: 7: break;
-: 8: a;
1: 9: continue; <- wrongly marked executed
-: 10: }
1: 11: continue;
-: 12: }
1: 13:}
Line 9 ("continue;") is unreachable: the preceding "break;" (line 7) exits
the for loop, so this statement should be reported as not executed (count 0),
not 1.
Reproduced on gcc 11.4.0, 13.1.0 and 17.0.0 trunk.