public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yangyibiao at outlook dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/97923] New: [GCOV]Wrong code coverage for multiple expressions with Logical OR Operator at multiple lines
Date: Fri, 20 Nov 2020 02:41:00 +0000	[thread overview]
Message-ID: <bug-97923-4@http.gcc.gnu.org/bugzilla/> (raw)

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.

             reply	other threads:[~2020-11-20  2:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20  2:41 yangyibiao at outlook dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-97923-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).