linux-mips
[Top] [All Lists]

Re: gcc crash

To: Kjeld Borch Egevang <kjelde@mips.com>
Subject: Re: gcc crash
From: Keith Owens <kaos@melbourne.sgi.com>
Date: Fri, 28 Sep 2001 22:37:52 +1000
Cc: linux-mips mailing list <linux-mips@oss.sgi.com>
In-reply-to: Your message of "Thu, 27 Sep 2001 16:59:47 +0200." <Pine.LNX.4.30.0109271657250.1742-100000@coplin19.mips.com>
Sender: owner-linux-mips@oss.sgi.com
On Thu, 27 Sep 2001 16:59:47 +0200 (CEST), 
Kjeld Borch Egevang <kjelde@mips.com> wrote:
>When I compile the following function with "gcc -O2" the compiler crashes.
>static float sp_f2l(float x)
>{
>    long l, *xl;
>    float y;
>
>    xl = (void *)&y;
>    l = x;
>    *xl = l;
>    return y;
>}

You are breaking the C rules for data accesses.  Compile with
-fno-strict-aliasing if you want to break the rules.  Or, and this is
much better, use a union of long and float to "convert" one
representation to another.


<Prev in Thread] Current Thread [Next in Thread>