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/97924] New: [GCOV]incorrect coverage for "?:" statement falls in different lines Date: Fri, 20 Nov 2020 03:16:24 +0000 [thread overview] Message-ID: <bug-97924-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2020-11-20 3:16 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-20 3:16 yangyibiao at outlook dot com [this message] 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
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-97924-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: linkBe 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).