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