https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101554
Bug ID: 101554
Summary: [GCOV] The coverage of "for" goes wrong.
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: njuwy at smail dot nju.edu.cn
CC: marxin at gcc dot gnu.org
Target Milestone: ---
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++
-disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)
$ cat test.c
#include<stdlib.h>
int a[251];
int __attribute__((noinline)) t(int i) {
if (i == 0)
exit(0);
if (i > 255)
abort();
}
int main() {
unsigned int i;
for (i = 0;; i++) {
a[i] = t((unsigned char)(i + 5));
}
}
$ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
libgcov profiling error:/home/wangyang/coverage/test/test.gcda:overwriting an
existing profile data with a different timestamp
File 'test.c'
Lines executed:88.89% of 9
Creating 'test.c.gcov'
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 1:#include<stdlib.h>
-: 2:int a[251];
252: 3:int __attribute__((noinline)) t(int i) {
252: 4: if (i == 0)
1: 5: exit(0);
251: 6: if (i > 255)
#####: 7: abort();
251: 8:}
1: 9:int main() {
-: 10: unsigned int i;
1: 11: for (i = 0;; i++) {
252: 12: a[i] = t((unsigned char)(i + 5));
-: 13: }
-: 14:}
Line 11 was executed 252 times