https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90420
--- Comment #6 from Yibiao Yang <yangyibiao at nju dot edu.cn> --- (In reply to Martin Liška from comment #1) > > $ gcc -O3 -g --coverage small.c; ./a.out; gcov small.c; cat small.c.gcov > > File 'small.c' > > Lines executed:78.57% of 14 > > Creating 'small.c.gcov' > > > > -: 0:Source:small.c > > -: 0:Graph:small.gcno > > -: 0:Data:small.gcda > > -: 0:Runs:1 > > -: 1:#define N 1000 > > -: 2: > > -: 3:int argc = 1; > > -: 4: > > #####: 5:int func (int *p, int *q) { > > 1001*: 6: int x = 0; > > #####: 7: for (int i = 0; i < N; i++) { > > 1000*: 8: x += (q[i] + p[i]); > > -: 9: } > > 1*: 10: return x; > > -: 11:} > > -: 12: > > 1: 13:int main () > > -: 14:{ > > 1: 15: int x = 0; > > 1: 16: int A1[N], A2[N]; > > -: 17: > > 1001: 18: for (int i = 0; i < N; i++) { > > 1000: 19: A1[i] = 5 + argc; > > 1000: 20: A2[i] = 1; > > -: 21: } > > -: 22: > > 1001: 23: x = func (A1, A2); > > -: 24: > > 1: 25: if (x != N * 7) > > #####: 26: return 1; > > -: 27: > > -: 28: return 0; > > -: 29:} > > > > > > When using "-O3" optimization, Line #6 and Line #22 are wrongly marked as > > I can't see Line #22 being executed. > > With 9.1.0 I see: > > -: 0:Source:pr90420.c > -: 0:Graph:pr90420.gcno > -: 0:Data:pr90420.gcda > -: 0:Runs:1 > -: 1:#define N 1000 > -: 2: > -: 3:int argc = 1; > -: 4: > #####: 5:int func (int *p, int *q) { > -: 6: int x = 0; > 1001*: 7: for (int i = 0; i < N; i++) { > 1000*: 8: x += (q[i] + p[i]); > -: 9: } > #####: 10: return x; > -: 11:} > -: 12: > 1: 13:int main () > -: 14:{ > -: 15: int x = 0; > -: 16: int A1[N], A2[N]; > -: 17: > 1001: 18: for (int i = 0; i < N; i++) { > 1000: 19: A1[i] = 5 + argc; > 1000: 20: A2[i] = 1; > -: 21: } > -: 22: > -: 23: x = func (A1, A2); > -: 24: > 1: 25: if (x != N * 7) > #####: 26: return 1; > -: 27: > -: 28: return 0; > -: 29:} > > which should be reasonable good. of this code : #####: 5:int func (int *p, int *q) { -: 6: int x = 0; 1001*: 7: for (int i = 0; i < N; i++) { 1000*: 8: x += (q[i] + p[i]); -: 9: } #####: 10: return x; -: 11:} Line #5 is marked as not executed. I understand that this function might be optimized as an inline function. However, since Line #7 and Line #8 is marked as executed and Line #5 is marked as not executed. This might mislead others when debugging or testing based on code coverage.