https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65357
Bug ID: 65357 Summary: aggressive loop optimization not correct Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: weiming at ms1 dot url.com.tw source: #include <stdio.h> #include <stdlib.h> void addlist(int n, int *list) { int i; for (i=0; i<n; i++) { *list++=*list+10; *list++=*list+11; } } int tlist[10]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; void main(void) { int i; addlist(5, tlist); for (i=0; i<10; i++) { fprintf(stdout, "%d: %d\n", i, tlist[i]); } } makefile: tt.exe: tt.c gcc -O3 -o $@ $< result of gcc 4.7.3: 0: 10 1: 12 2: 12 3: 14 4: 14 5: 16 6: 16 7: 18 8: 18 9: 20 result of gcc 4.8.4 and 4.9.2: 0: 11 1: 13 2: 13 3: 15 4: 15 5: 17 6: 17 7: 19 8: 19 9: 11 which is correct?