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.