From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4223 invoked by alias); 16 Sep 2005 11:10:24 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3538 invoked by uid 48); 16 Sep 2005 11:09:33 -0000 Date: Fri, 16 Sep 2005 11:10:00 -0000 From: "larschri at pvv dot ntnu dot no" To: gcc-bugs@gcc.gnu.org Message-ID: <20050916110930.23913.larschri@pvv.ntnu.no> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/23913] New: float/int binary conversion -- "-O2 -march=i686" X-Bugzilla-Reason: CC X-SW-Source: 2005-09/txt/msg01983.txt.bz2 List-Id: Full example files are here: http://www.pvv.ntnu.no/~larschri/cast-bug/ The compiled program fails to do binary conversion between float and int. Both sizeof(int) and sizeof(float) is 4, so the two floats below should have the same binary representation after being written/read to/from the integer object. float f1 = 4.5; int i = *((int*)&f1); float f2 = *((float*)&i); assert(f1 == f2); $ gcc --version gcc (GCC) 4.0.1 20050727 (Red Hat 4.0.1-5) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ gcc -O2 -march=i686 cast-bug.c $ ./a.out a.out: cast-bug.c:8: main: Assertion `f1 == f2' failed. Aborted -- Summary: float/int binary conversion -- "-O2 -march=i686" Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: larschri at pvv dot ntnu dot no CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23913