https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121897
Bug ID: 121897
Summary: Wrong line coverage for if else with function call.
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#L696
2. https://sources.debian.org/src/ifupdown/0.8.41/main.c#L838
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'
int foo() {
return 0;
}
void main() {
int m = 1;
if ((m == 0) || (m == 1)) {
int n = foo();
} else {
return;
}
}
EOF
$ gcc --coverage test.c -o test
$ ./test
$ gcov test
$ cat test.c.gcov
...
1: 1:int foo() {
1: 2: return 0;
-: 3:}
-: 4:
1: 5:void main() {
1: 6: int m = 1;
2: 7: if ((m == 0) || (m == 1)) {
1: 8: int n = foo();
-: 9: } else {
#####: 10: return;
-: 11: }
-: 12:}
...
Line coverage at line 7 should not be 2 but 1.