public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/97924] New: [GCOV]incorrect coverage for "?:" statement falls in different lines
@ 2020-11-20  3:16 yangyibiao at outlook dot com
  2020-11-20  9:38 ` [Bug gcov-profile/97924] " marxin at gcc dot gnu.org
  2020-11-20  9:38 ` marxin at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: yangyibiao at outlook dot com @ 2020-11-20  3:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97924
           Summary: [GCOV]incorrect coverage for "?:" statement falls in
                    different 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

#include <string.h>

struct S { int *obj; };

void *foo() { return 0; }

void bar(struct S *r)
{
  r->obj = 
     (int *)(r->obj != ((void *)0) ? ({void *v=0; v;}) : foo());
}

int main(void)
{
  struct S r;
  memset(&r, 0, sizeof(struct S));
  bar(&r);
}


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

        -:    0:Source:test.c
        -:    0:Graph:test.gcno
        -:    0:Data:test.gcda
        -:    0:Runs:1
        -:    1:
        -:    2:#include <string.h>
        -:    3:
        -:    4:struct S { int *obj; };
        -:    5:
        1:    6:void *foo() { return 0; }
        -:    7:
        1:    8:void bar(struct S *r)
        -:    9:{
       2*:   10:  r->obj = 
       1*:   11:     (int *)(r->obj != ((void *)0) ? ({void *v=0; v;}) :
foo());
        1:   12:}
        -:   13:
        1:   14:int main(void)
        -:   15:{
        -:   16:  struct S r;
        1:   17:  memset(&r, 0, sizeof(struct S));
        1:   18:  bar(&r);
        -:   19:}


###############
Line 10 is marked as executed 2 times. However, it should be execute only once
as when debut this program in debugger, it hit only once.

I am not sure it is a bug in coverage profiler as the "?:" statement is at
another line of code.

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

* [Bug gcov-profile/97924] [GCOV]incorrect coverage for "?:" statement falls in different lines
  2020-11-20  3:16 [Bug gcov-profile/97924] New: [GCOV]incorrect coverage for "?:" statement falls in different lines yangyibiao at outlook dot com
@ 2020-11-20  9:38 ` marxin at gcc dot gnu.org
  2020-11-20  9:38 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-20  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, that's who we expand that:

  <bb 2> :
  [pr97924.c:10:15] _1 = [pr97924.c:10:15] r_5(D)->obj;
  [pr97924.c:9:10] if (_1 != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 3> :
  [pr97924.c:10:46] v_8 = 0B;
  [pr97924.c:10:51] _9 = v_8;
  [pr97924.c:9:10] iftmp.0_10 = _9;
  [0:0] goto <bb 5>; [INV]

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

* [Bug gcov-profile/97924] [GCOV]incorrect coverage for "?:" statement falls in different lines
  2020-11-20  3:16 [Bug gcov-profile/97924] New: [GCOV]incorrect coverage for "?:" statement falls in different lines yangyibiao at outlook dot com
  2020-11-20  9:38 ` [Bug gcov-profile/97924] " marxin at gcc dot gnu.org
@ 2020-11-20  9:38 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-20  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-11-20
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

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

end of thread, other threads:[~2020-11-20  9:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20  3:16 [Bug gcov-profile/97924] New: [GCOV]incorrect coverage for "?:" statement falls in different lines yangyibiao at outlook dot com
2020-11-20  9:38 ` [Bug gcov-profile/97924] " marxin at gcc dot gnu.org
2020-11-20  9:38 ` marxin at gcc dot gnu.org

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