From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53258 invoked by alias); 25 May 2015 21:27:45 -0000 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 Received: (qmail 53014 invoked by uid 48); 25 May 2015 21:27:42 -0000 From: "timo.kreuzer at reactos dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66282] New: Missing x86 floating point conversion on explicit casts violates C standard Date: Mon, 25 May 2015 21:27:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: timo.kreuzer at reactos dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg02080.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66282 Bug ID: 66282 Summary: Missing x86 floating point conversion on explicit casts violates C standard Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: timo.kreuzer at reactos dot org Target Milestone: --- When compiling floating point code, the compiler omits to convert an intermediate computation result, which is cast to double, to 64 bit precision and instead keeps the internal 80 bit precision. Example code: void bugbug() { double x = 4.4; double y; y = (1 / x); if ( y != ((double)(1 / x)) ) { printf("Standard violation!\n"); } } compiled with "gcc.exe -Wall -g -c fpu.c -o fpu.o" The expression on the right side inside the if() is not converted to double precision, which is in violation of the C standard. Quote: "Implementations employing wide registers have to take care to honor appropriate semantics. Values are independent of whether they are represented in a register or in memory. For example, an implicit spilling of a register is not permitted to alter the value. Also, an explicit store and load is required to round to the precision of the storage type. In particular, casts and assignments are required to perform their specified conversion." Emphasis is on the last sentence. This was tested on a mingw version of the compiler, but I do not think this is mingw specific.