public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/97910] New: [GCOV]"&&" lead to incorrect code coverage when multiple expressions of a single statement fall in different lines
@ 2020-11-19 16:41 yangyibiao at outlook dot com
2020-11-20 9:09 ` [Bug gcov-profile/97910] " marxin at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: yangyibiao at outlook dot com @ 2020-11-19 16:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97910
Bug ID: 97910
Summary: [GCOV]"&&" lead to incorrect code coverage when
multiple expressions of a single statement fall 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
struct hx {
int a, b, c;
} __attribute__ ((aligned));
static struct hx x = {0xc11f, 0xc22f, ~1};
static struct hx y = {0xfd10, 0xfe20, ~2};
int f()
{
return ((x.a & 0x3ff0) == (y.a & 0x03ff) &&
(x.b & 0x3ff0) == (y.b & 0x03ff));
}
int main() { f(); }
$ gcc -O0 --coverage test.c; ./a.out; gcov test.c; cat test.c.gcov
File 'test.c'
Lines executed:100.00% of 4
Creating 'test.c.gcov'
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:struct hx {
-: 2: int a, b, c;
-: 3:} __attribute__ ((aligned));
-: 4:
-: 5:static struct hx x = {0xc11f, 0xc22f, ~1};
-: 6:static struct hx y = {0xfd10, 0xfe20, ~2};
-: 7:
1: 8:int f()
-: 9:{
2*: 10: return ((x.a & 0x3ff0) == (y.a & 0x03ff) &&
1: 11: (x.b & 0x3ff0) == (y.b & 0x03ff));
-: 12:}
-: 13:
1: 14:int main() { f(); }
################################
We can found that Line #10 is wrongly marked as executed twice.
When debug this program in debugger, Line 10 is only hit once.
Note that: When Line 10 and Line 11 in the same line, the result will be
correct.
$ gcc --version; gcov --version
gcc (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcov (GCC) 10.0.1 20200419 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug gcov-profile/97910] [GCOV]"&&" lead to incorrect code coverage when multiple expressions of a single statement fall in different lines
2020-11-19 16:41 [Bug gcov-profile/97910] New: [GCOV]"&&" lead to incorrect code coverage when multiple expressions of a single statement fall in different lines yangyibiao at outlook dot com
@ 2020-11-20 9:09 ` marxin at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-11-20 9:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97910
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-11-20
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, it's related to how we generate code for the condition:
<bb 2> :
[pr97910.c:10:13] _1 = [pr97910.c:10:13] x.a;
[pr97910.c:10:16] _2 = _1 & 16368;
[pr97910.c:10:31] _3 = [pr97910.c:10:31] y.a;
[pr97910.c:10:34] _4 = _3 & 1023;
[pr97910.c:10:44] if (_2 == _4)
goto <bb 3>; [INV]
else
goto <bb 5>; [INV]
<bb 3> :
[pr97910.c:11:6] _5 = [pr97910.c:11:6] x.b;
[pr97910.c:11:9] _6 = _5 & 16368;
[pr97910.c:11:24] _7 = [pr97910.c:11:24] y.b;
[pr97910.c:11:27] _8 = _7 & 1023;
[pr97910.c:10:44] if (_6 == _8)
goto <bb 4>; [INV]
else
goto <bb 5>; [INV]
<bb 4> :
[pr97910.c:10:44] iftmp.0_11 = 1;
[pr97910.c:10:44] goto <bb 6>; [INV]
<bb 5> :
[pr97910.c:10:44] iftmp.0_12 = 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-20 9:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-19 16:41 [Bug gcov-profile/97910] New: [GCOV]"&&" lead to incorrect code coverage when multiple expressions of a single statement fall in different lines yangyibiao at outlook dot com
2020-11-20 9:09 ` [Bug gcov-profile/97910] " 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).