https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79891
Bug ID: 79891
Summary: Wrong count of
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: manfred.melzig at web dot de
Target Milestone: ---
Following situation has been extracted form real code:
#include <stdlib.h> /* for exit() */
unsigned int UuT(void)
{
unsigned int true_var = 1;
unsigned int false_var = 0;
unsigned int ReturnStatus_t = 0;
if (false_var) {
ReturnStatus_t = 1;
}
else {
if (true_var) {
if (true_var) {
ReturnStatus_t = 0;
}
else {
if (true_var) {
ReturnStatus_t = 0;
}
else {
**/* Following line falsely marked as covered
when parameter "--rc lcov_branch_coverage=1" is set */**
ReturnStatus_t = 0;
}
}
}
else {
ReturnStatus_t = 0;
}
}
return (ReturnStatus_t);
}
int main(int argc, char** argv) {
UuT();
return 0;
}
Invoking gcov -a Test.c produce a wrong count of line coverage:
[...]
-: 28: else {
-: 29: /* Following line
falsely marked as covered when parameter "--rc lcov_branch_coverage=1" is set
*/
1: 30: ReturnStatus_t = 0;
$$$$$: 30-block 0
1: 30-block 1
-: 31: }
-: 32: }
[...]
without parameter -a it looks fine:
[...]
-: 28: else {
-: 29: /* Following line
falsely marked as covered when parameter "--rc lcov_branch_coverage=1" is set
*/
#####: 30: ReturnStatus_t = 0;
-: 31: }
-: 32: }
[...]
Used version (in cygwin):
gcc 6.3.0
gcov 6.3.0
The invoked script:
#!/bin/bash
[ "$COMSPEC" ] && set -o igncr; # Ignore CR if on Windows system
gcc -O0 -g3 -ftest-coverage -fprofile-arcs -Wall -c -fmessage-length=0 -MMD -MP
-MF"Test.d" -MT"Test.o" -o "Test.o" "Test.c"
gcc -ftest-coverage -fprofile-arcs -Wall -Wextra -o "Test.exe" ./Test.o
./Test.exe
gcov -a Test.c
For me it looks like a bug and I hope the effect is reproducible.
Best regards
MMelzig