https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100980
Bug ID: 100980 Summary: [GCOV]The assignment statement in the “for” structure caused the wrong coverage 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<stdio.h> extern void abort(void); extern void exit(int); int main(void) { struct foo{ int i0; }; int b,c,d=1; for ((b = sizeof(struct foo { int i0; int i1; })); d; d--) c = sizeof(struct foo); } $ gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov File 'test.c' Lines executed:100.00% of 5 Creating 'test.c.gcov' -: 0:Source:test.c -: 0:Graph:test.gcno -: 0:Data:test.gcda -: 0:Runs:1 -: 1:#include<stdio.h> -: 2:extern void abort(void); -: 3:extern void exit(int); 1: 4:int main(void) { -: 5: struct foo{ -: 6: int i0; -: 7:}; 1: 8: int b,c,d=1; 2: 9: for ((b = sizeof(struct foo { -: 10: int i0; -: 11: int i1; -: 12: })); 1: 13: d; d--) 1: 14:c = sizeof(struct foo); -: 15:} line 9 was wrongly marked as executed 2 times