https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84572
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P5
Status|ASSIGNED |NEW
Assignee|marxin at gcc dot gnu.org |unassigned at gcc dot
gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced test-case:
$ cat gcov.c
int a, b;
void foo (int value)
{
if (value == 1 || value == 2 || (value >= 33 && value <= 44))
{
a = 1;
if (value == 2)
b = 2;
}
else
a = 4;
}
int main(int argc, char **argv)
{
foo (argc);
}
$ cat gcov.c.gcov
-: 0:Source:gcov.c
-: 0:Graph:gcov.gcno
-: 0:Data:gcov.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:int a, b;
-: 2:
1: 3:void foo (int value)
-: 4:{
1*: 5: if (value == 1 || value == 2 || (value >= 33 && value <= 44))
-: 6: {
1: 7: a = 1;
2: 8: if (value == 2)
1: 9: b = 2;
-: 10: }
-: 11: else
#####: 12: a = 4;
1: 13:}
-: 14:
-: 15:
1: 16:int main(int argc, char **argv)
-: 17:{
1: 18: foo (argc);
-: 19:}
As you can see, there's a duplicate expression (value == 2) on lines 5 and 8.
Even with -O0 we do some optimizations and the expression is executed just
once. That's why we report line 8 twice.
Note that we have couple of similar issue caused by similar optimization.