[Bug tree-optimization/96801] New: Refactoring of LIM introduced possible bug
stefansf at linux dot ibm.com
gcc-bugzilla@gcc.gnu.org
Wed Aug 26 16:24:32 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96801
Bug ID: 96801
Summary: Refactoring of LIM introduced possible bug
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: stefansf at linux dot ibm.com
Target Milestone: ---
Consider the following example:
int a = 0, f = 0, g = 0, h = 0, i = 0;
int b = 0;
static int c[1][1];
static int *const d = &c[0][0];
int *e = 0;
int main() {
for (; i < 1; i++) { // LOOP-A
for (; b != 0; b++) // LOOP-B
if (f != 0) {
*e = (*d)--;
break;
}
}
for (g = 0; g < 1; g++) { // LOOP-C
for (h = 0; h < 1; h++) // LOOP-D
a = a ^ c[g][h];
}
printf("checksum = %X\n", a);
return a;
}
Basically LOOP-A does nothing since the condition of inner LOOP-B never
evaluates to true. Thus we are left with LOOP-C which runs exactly one time as
does LOOP-D. Expression a ^ c[g][h] should evaluate to 0 since a as well as
c[0][0] are 0. In total we would expect to see "checksum = 0" being printed.
This is the case for me prior commit 6aec53ee4f7. With this commit "random"
numbers are printed.
Can someone confirm this?
More information about the Gcc-bugs
mailing list