From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29696 invoked by alias); 15 May 2015 19:24:59 -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 29670 invoked by uid 48); 15 May 2015 19:24:55 -0000 From: "d.a.gonzalez.marquez at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66164] New: Strange behaviour calling functions with float as parameter Date: Fri, 15 May 2015 19:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.8.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: d.a.gonzalez.marquez at gmail dot com 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 attachments.created 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/msg01216.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66164 Bug ID: 66164 Summary: Strange behaviour calling functions with float as parameter Product: gcc Version: 4.8.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: d.a.gonzalez.marquez at gmail dot com Target Milestone: --- Created attachment 35550 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35550&action=edit Source code for reproduce the bug The following bug is for x86 architecture on a i386 compilation: -m32 I took a code that is part of an implementation of the libc. In order to obtain a new one with some changes. The problem was that I found a bug. The code is easy to follow: It makes calls in this order: main ---> AUXsin ---> __sinf ---> __ieee754_rem_pio2f int main() { float ra = AUXsin(100); return 0; } float AUXsin(float x) { return __sinf(x); } float __sinf(float x) { float y[2],z=0.0; int32_t n, ix; n = __ieee754_rem_pio2f(x,y); return (float)n; } int32_t __ieee754_rem_pio2f(float x, float *y) { y[0] = 0.0; return 0; } When the function __ieee754_rem_pio2f tries to read the parameter y, it finds that the stack is: esp - 4 | ........ esp + 0 | return addr esp + 4 | value x esp + 8 | value x esp + 12 | pointer to y The problem was that the function __sinf store a double on the stack for the x value. And, when the function tries to read the pointer to y, it reads a wrong value. I attached a zip with the code to test. Thanks in advance, David