From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9485 invoked by alias); 19 May 2010 18:00:50 -0000 Received: (qmail 9390 invoked by uid 48); 19 May 2010 18:00:35 -0000 Date: Wed, 19 May 2010 18:00:00 -0000 Subject: [Bug c/44198] New: Constant floating point values are mutable (with '-O1') X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "AlekM at hotmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-05/txt/msg02100.txt.bz2 The example code below, compiled on x86 with gcc versions 4.1.2 through 4.4.0, aborts when executed. #include #include 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