The example code below, compiled on x86 with gcc versions 4.1.2 through 4.4.0, aborts when executed.
#include <stdlib.h> #include <assert.h> int main(void)__attribute__ ((optimize("O1"))); // Also with '-O2' int main(void) { const float a = rand(); // Any function call that returns 1804289383 will do volatile float tmp=a; assert(tmp==a); // This one aborts assert(tmp==a); // This one passes (if line above is replaced with printf) } If you replace assert() with two consecutive printf("%f ", a), two different values are displayed for the constant variable a. -- Summary: Constant floating point values are mutable (with '-O1') Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: AlekM at hotmail dot com GCC build triplet: gcc version 4.4.0 20090514 (Red Hat 4.4.0-6) (GCC) GCC host triplet: Linux hld-lx 2.6.18-128.7.1.el5 #1 SMP Mon Aug 24 08:20:55 EDT 2 GCC target triplet: same as above http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44198