From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3FEBB3870876; Fri, 20 Nov 2020 03:16:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FEBB3870876 From: "yangyibiao at outlook dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: yangyibiao at outlook dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Nov 2020 03:16:24 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97924 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 struct S { int *obj; }; void *foo() { return 0; } void bar(struct S *r) { r->obj =3D=20 (int *)(r->obj !=3D ((void *)0) ? ({void *v=3D0; 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 -: 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 =3D=20 1*: 11: (int *)(r->obj !=3D ((void *)0) ? ({void *v=3D0; 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 o= nce 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.=