struct S { int *s; }; void test (int x, struct S *y) { int i; for (i = 0; i < x; i++) { if (y) y->s[i] += 1; } }
int main () { test (1, (void *) 0); return 0; } is miscompiled at -O2 in 4.1.x, works with -O2 -fno-strength-reduction or -O2 -floop-optimize2, works with 3.2.x, 3.4.x and 4.2. -- Summary: [4.1 Regression] Strength reduction bug Product: gcc Version: 4.1.2 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org GCC target triplet: x86_64-linux, i?86-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30787