https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65307
Bug ID: 65307 Summary: Incorrect optimization breaks basic arithmetic Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: madars+gccbug at gmail dot com The following code sample exhibits a bug in a gcc -O2 optimization pass. Namely, having defined two() and six() with the obvious return values, the value of two() * 2 + six() * 5 gets an assembly of 1 shl 5 (i.e. 32, instead of the correct 34). Code: http://web.mit.edu/madars/Public/gcc-basic-arithmetic-bug.c gcc 4.9.1 and 4.9.2 with -O2 are both buggy, -O1 makes the bug go away; the bug does not seem to be present in gcc 4.8 and earlier.