public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/97923] New: [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines
@ 2020-11-20  2:41 yangyibiao at outlook dot com
  2020-11-20  9:35 ` [Bug gcov-profile/97923] " marxin at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: yangyibiao at outlook dot com @ 2020-11-20  2:41 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-01  2:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20  2:41 [Bug gcov-profile/97923] New: [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines yangyibiao at outlook dot com
2020-11-20  9:35 ` [Bug gcov-profile/97923] " marxin at gcc dot gnu.org
2022-09-08  7:49 ` yangyibiao at nju dot edu.cn
2022-09-08  9:42 ` marxin at gcc dot gnu.org
2022-09-08 11:13 ` yangyibiao at nju dot edu.cn
2023-03-01  2:07 ` yinyuefengyi at gmail dot com
2023-03-01  2:10 ` yinyuefengyi at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).