[Bug middle-end/84433] gcc 7 and before miscompile loop and remove exit due to incorrect range calculation
acsawdey at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 19 14:24:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84433
--- Comment #8 from acsawdey at gcc dot gnu.org ---
It looks like both gcc 7 and 8 assume that the statement
ptrA->sA[ptrB->int1].zt = parm1;
will only be executed 14+1 times because of the declaration sA[15].
However gcc 7 assumes the whole loop will only execute that number of times:
Statement ptrA_14(D)->sA[ptrB__int1_lsm.11_22].zt = _34;
is executed at most 14 (bounded by 14) + 1 times in loop 1.
Analyzing # of iterations of loop 1
exit condition [15, + , 4294967295] != 0
bounds on difference of bases: -15 ... -15
result:
# of iterations 15, bounded by 15
Loop 1 iterates 15 times.
Loop 1 iterates at most 14 times.
Loop 1 likely iterates at most 14 times.
Analyzing # of iterations of loop 1
exit condition [15, + , 4294967295] != 0
bounds on difference of bases: -15 ... -15
result:
# of iterations 15, bounded by 15
Removed pointless exit: if (ivtmp_24 != 0)
were gcc8 does not:
Statement ptrA_13(D)->sA[ptrB__int1_lsm.5_22].zt = _20;
is executed at most 14 (bounded by 14) + 1 times in loop 1.
Analyzing # of iterations of loop 1
exit condition [15, + , 4294967295] != 0
bounds on difference of bases: -15 ... -15
result:
# of iterations 15, bounded by 15
Loop 1 iterates 15 times.
Loop 1 iterates at most 15 times.
Loop 1 likely iterates at most 15 times.
Neither gcc 7 nor 8 produce any warnings for the revised test case with -Wall.
More information about the Gcc-bugs
mailing list