https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85225
Bug ID: 85225 Summary: [GCOV] An array reference in the for(;;) loop will lead the loop be marked as wrong execution times in gcov Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: yangyibiao at nju dot edu.cn CC: marxin at gcc dot gnu.org Target Milestone: --- $ cat small.c void main() { int a = 1; for (;;) { int b[1] = {0}; b[0]; if (a) { a = 0; } else break; } } $ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat small.c.gcov File 'small.c' Lines executed:100.00% of 8 Creating 'small.c.gcov' -: 0:Source:small.c -: 0:Graph:small.gcno -: 0:Data:small.gcda -: 0:Runs:1 -: 0:Programs:1 1: 1:void main() { 1: 2: int a = 1; 1: 3: for (;;) { 2: 4: int b[1] = {0}; -: 5: b[0]; 2: 6: if (a) { 1: 7: a = 0; -: 8: } else 1: 9: break; -: 10: } 1: 11:} Line #3 is marked as executed once. In fact, it should have executed twice.