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.