https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63602
Bug ID: 63602 Summary: Wrong code w/ -O2 -ftree-loop-linear Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: asolokha at gmx dot com gcc produces wrong code w/ -ftree-loop-linear -O2 (and above) for the following reduced case: int sx; int bn; int vz = 1; int *volatile n6 = &bn; int main(void) { for (int i = 0; i < 3; ++i) { sx = vz; vz = bn; } return sx; } It struck me first w/ gcc-4.10.0-alpha20140810, but today I've reproduced it w/ 4.8.3, 4.9.1 and 5-alpha20141019, so I'm not marking it as a regression. Expected results: % gcc-5.0_alpha20141019 -O2 -o good 963b8772.c % ./good % echo $? 0 Actual results: % gcc-5.0_alpha20141019 -O2 -ftree-loop-linear -o bad 963b8772.c % ./bad % echo $? 1