[Bug gcov-profile/97923] New: [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines

yangyibiao at outlook dot com gcc-bugzilla@gcc.gnu.org
Fri Nov 20 02:41:00 GMT 2020


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

            Bug ID: 97923
           Summary: [GCOV]Wrong code coverage for multiple expressions
                    with Logical OR Operator at multiple lines
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at outlook dot com
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat test.c
int foo(int c)
{
  return ((c >= 'A' && c <= 'Z')
       || (c >= 'a' && c <= 'z')
       || (c >= '0' && c <= '0'));
}

int main() { foo(0); }


$ gcc -O0 --coverage test.c; ./a.out; gcov test.c; cat test.c.gcov
File 'test.c'
Lines executed:80.00% of 5
Creating 'test.c.gcov'

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        1:    1:int foo(int c)
        -:    2:{
    #####:    3:  return ((c >= 'A' && c <= 'Z')
       1*:    4:       || (c >= 'a' && c <= 'z')
       2*:    5:       || (c >= '0' && c <= '0'));
        -:    6:}
        -:    7:
        1:    8:int main() { foo(0); }


###################################
Line 5 is wrongly marked as executed twice. 
When debug this program in debugger, Line 5 is only hit once.


$ gcc --version; gcov --version
gcc (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 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.

gcov (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 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.


More information about the Gcc-bugs mailing list