https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85274
Bug ID: 85274 Summary: [GCOV] A return statement in if(0) block is wrongly marked as executed when they are nested in for(;1;) statement and prefixed with an struct declaration and followed by a assignment statement 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 struct s {int s1;}; int a = 0; int main() { for (; 1;) { struct s g; if (0) return 2; return 0; a = 0; } return 0; } $ gcc -w --coverage small.c; ./a.out; gcov-8 small.c; cat smal.c.gcov File 'small.c' Lines executed:80.00% of 5 Creating 'small.c.gcov' -: 0:Source:small.c -: 0:Graph:small.gcno -: 0:Data:small.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:struct s {int s1;}; -: 2:int a = 0; 1: 3:int main() { 1: 4: for (; 1;) { -: 5: struct s g; -: 6: if (0) 1: 7: return 2; 1: 8: return 0; -: 9: a = 0; -: 10: } #####: 11: return 0; -: 12:} ****** Line #7 is wrongly marked as executed. while removing any of Line #5 or Line #9, the result is correct.