public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "yangyibiao at nju dot edu.cn" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug gcov-profile/105500] New: [Gcov]wrong freqency for the while loop with struct in the expression
Date: Fri, 06 May 2022 03:11:11 +0000	[thread overview]
Message-ID: <bug-105500-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105500
           Summary: [Gcov]wrong freqency for the while loop with struct in
                    the expression
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: gcov-profile
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yangyibiao at nju dot edu.cn
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat small.c
struct S { int f; } a;

struct S foo (int x, struct S y)
{
  int b = y.f;
  return a; 
}

void bar ()
{
  while (a.f)
    {
      struct S c = {0};
      foo (0, c);
    }
}

int main ()
{
  bar (); 
  return 0;
}

$ gcc -O0 --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov
File 'small.c'
Lines executed:54.55% of 11
Creating 'small.c.gcov'

        -:    0:Source:small.c
        -:    0:Graph:small.gcno
        -:    0:Data:small.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:struct S { int f; } a;
        -:    2:
    #####:    3:struct S foo (int x, struct S y)
        -:    4:{
    #####:    5:  int b = y.f;
    #####:    6:  return a; 
        -:    7:}
        -:    8:
        1:    9:void bar ()
        -:   10:{
        2:   11:  while (a.f)
        -:   12:    {
    #####:   13:      struct S c = {0};
    #####:   14:      foo (0, c);
        -:   15:    }
        1:   16:}
        -:   17:
        1:   18:int main ()
        -:   19:{
        1:   20:  bar (); 
        1:   21:  return 0;
        -:   22:}

Line #11 is wrongly marked as executed twice which should be executed once.

             reply	other threads:[~2022-05-06  3:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06  3:11 yangyibiao at nju dot edu.cn [this message]
2022-05-06  6:11 ` [Bug gcov-profile/105500] " rguenth at gcc dot gnu.org
2022-05-10 11:29 ` marxin at gcc dot gnu.org

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-105500-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).