public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug gcov-profile/101342] New: [Gcov] Wrong coverage with "for(;;a++)" loop statement
@ 2021-07-06 12:21 byone.heng at gmail dot com
2021-07-06 12:48 ` [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a " byone.heng at gmail dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: byone.heng at gmail dot com @ 2021-07-06 12:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101342
Bug ID: 101342
Summary: [Gcov] Wrong coverage with "for(;;a++)" loop
statement
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: byone.heng at gmail dot com
CC: marxin at gcc dot gnu.org
Target Milestone: ---
$./gcc -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/home/x/project/gcc/build/install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/x/project/gcc/build/install
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210105 (experimental) (GCC)
$cat test.c
volatile long int true_var = 1;
const long int false_var = 0;
int a=0;
int main() {
for (;; a++) {
int c[1];
if( true_var > 0 )
{
if (a) {
break;
a;
continue; /* count(1) */
}
continue;
} /* count(1) */
}
return 0;
}
$gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
-: 1:/* { dg-options "-fprofile-arcs -ftest-coverage" } */
-: 2:/* { dg-do run { target native } } */
-: 3:
-: 4:volatile long int true_var = 1;
-: 5:const long int false_var = 0;
-: 6:
-: 7:int a=0;
-: 8:
2: 9:int main() {
1: 10: for (;; a++) {
-: 11: int c[1];
2: 12: if( true_var > 0 )
-: 13: {
2: 14: if (a) {
1: 15: break;
-: 16: a;
1: 17: continue; /* count(1) */
-: 18: }
1: 19: continue;
-: 20: } /* count(1) */
-: 21: }
-: 22:
1: 23: return 0;
-: 24:}
-: 25:
-: 26:/* { dg-final { run-gcov gcov-pr85217.c } } */
Line 10 is wrongly marked as executed once which should be executed twice.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a loop statement
2021-07-06 12:21 [Bug gcov-profile/101342] New: [Gcov] Wrong coverage with "for(;;a++)" loop statement byone.heng at gmail dot com
@ 2021-07-06 12:48 ` byone.heng at gmail dot com
2021-07-06 13:21 ` byone.heng at gmail dot com
2021-07-06 15:03 ` schwab@linux-m68k.org
2 siblings, 0 replies; 4+ messages in thread
From: byone.heng at gmail dot com @ 2021-07-06 12:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101342
Xiaoyuan Xie <byone.heng at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[Gcov] Wrong coverage with |[Gcov] wrong coverage for
|"for(;;a++)" loop |the function with a loop
|statement |statement
--- Comment #1 from Xiaoyuan Xie <byone.heng at gmail dot com> ---
$./gcc -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/home/x/project/gcc/build/install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/x/project/gcc/build/install
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210105 (experimental) (GCC)
$cat test.c
static short int true_var = 1;
signed char false_var = 0;
typedef unsigned V __attribute__ ((vector_size (16)));
V
foo (unsigned x, V v)
{
do {
v %= x;
x = 1;
} while (v[1]);
return v;
}
int
main ()
{
V x = foo (5, (V) { 0, 1 });
if (x[0] || x[1] || x[2] || x[3])
__builtin_abort();
return 0;
}
$gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
-: 1:/* { dg-do run } */
-: 2:/* { dg-additional-options "-w -Wno-psabi" } */
-: 3:
-: 4:static short int true_var = 1;
-: 5:signed char false_var = 0;
-: 6:
-: 7:typedef unsigned V __attribute__ ((vector_size (16)));
-: 8:
-: 9:V
2: 10:foo (unsigned x, V v)
-: 11:{
-: 12: do {
2: 13: v %= x;
2: 14: x = 1;
2: 15: } while (v[1]);
1: 16: return v;
-: 17:}
-: 18:
-: 19:int
1: 20:main ()
-: 21:{
1: 22: V x = foo (5, (V) { 0, 1 });
1: 23: if (x[0] || x[1] || x[2] || x[3])
#####: 24: __builtin_abort();
1: 25: return 0;
-: 26:}
In my opinion, line 10 should be executed one time.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a loop statement
2021-07-06 12:21 [Bug gcov-profile/101342] New: [Gcov] Wrong coverage with "for(;;a++)" loop statement byone.heng at gmail dot com
2021-07-06 12:48 ` [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a " byone.heng at gmail dot com
@ 2021-07-06 13:21 ` byone.heng at gmail dot com
2021-07-06 15:03 ` schwab@linux-m68k.org
2 siblings, 0 replies; 4+ messages in thread
From: byone.heng at gmail dot com @ 2021-07-06 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101342
--- Comment #2 from Xiaoyuan Xie <byone.heng at gmail dot com> ---
I clicked the wrong button on my page and the same content was submitted twice,
please ignore the content in the description and directly read the comments 1.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a loop statement
2021-07-06 12:21 [Bug gcov-profile/101342] New: [Gcov] Wrong coverage with "for(;;a++)" loop statement byone.heng at gmail dot com
2021-07-06 12:48 ` [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a " byone.heng at gmail dot com
2021-07-06 13:21 ` byone.heng at gmail dot com
@ 2021-07-06 15:03 ` schwab@linux-m68k.org
2 siblings, 0 replies; 4+ messages in thread
From: schwab@linux-m68k.org @ 2021-07-06 15:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101342
--- Comment #3 from Andreas Schwab <schwab@linux-m68k.org> ---
*** Bug 101341 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-07-06 15:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 12:21 [Bug gcov-profile/101342] New: [Gcov] Wrong coverage with "for(;;a++)" loop statement byone.heng at gmail dot com
2021-07-06 12:48 ` [Bug gcov-profile/101342] [Gcov] wrong coverage for the function with a " byone.heng at gmail dot com
2021-07-06 13:21 ` byone.heng at gmail dot com
2021-07-06 15:03 ` schwab@linux-m68k.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).