Bug 5590 - Float'Image unreliable with zero, Is_Negative intrisic to blame
Summary: Float'Image unreliable with zero, Is_Negative intrisic to blame
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: 3.3
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2002-02-04 11:06 UTC by minyard
Modified: 2003-12-17 20:42 UTC (History)
1 user (show)

See Also:
Host: powerpc-unknown-linux
Target: powerpc-unknown-linux
Build: powerpc-unknown-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
tester (335 bytes, application/octet-stream)
2003-05-21 15:15 UTC, minyard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description minyard 2002-02-04 11:06:22 UTC
I ran a test suite I had for Ada, and I only ran into one small problem. I've traced it down to the Is_Negative Ada intrinsic not working reliably when compiled with -O2.  It doesn't reliably work for zero, it sometimes detects 0.0 is -0.0, and sometimes vice versa (probably depends on the code around it).  This is just for PPC, for x86 it works fine.  I haven't done much more to track this down, and I don't know much about IEEE floating point, but the actual code for negative detection seems odd.  Why not just check the sign bit?



Should produce the following output:

Val: ' 0.00000E+00'
Val: ' 0.00000E+00'
Constant
Variable

On the PPC, it produces the following output:

Val: '0.00000E+00'   <= Notice there is no space here at the beginning
Val: '-0.00000E+00'
Constant
Is Negative 2 <= The value should not be negative.
Variable
Is Negative 2 <= The value should not be negative.

If you move things around and change things, the behaviour changes.

Release:
Current gcc 3.1 tree

Environment:
Linux/PPC

How-To-Repeat:
Compile and run the attached code under Linux/PPC, it produces:

Val: '0.00000E+00'   <= Notice there is no space here at the beginning
Val: '-0.00000E+00'
Constant
Is Negative 2 <= The value should not be negative.
Variable
Is Negative 2 <= The value should not be negative.

The output should be:

Val: ' 0.00000E+00'
Val: ' 0.00000E+00'
Constant
Variable
Comment 1 Dara Hazeghi 2003-05-10 14:26:33 UTC
From: Dara Hazeghi <dhazeghi@yahoo.com>
To: gcc-gnats@gcc.gnu.org, minyard@acm.org
Cc:  
Subject: Re: ada/5590: Float'Image unreliable with zero, Is_Negative intrisic to blame
Date: Sat, 10 May 2003 14:26:33 -0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- 
 trail&database=gcc&pr=5590
 
 Hello,
 
 your PR indicates that the testcase failed on 3.1. Would it be possible  
 to test whether this problem still occurs on a more current version of  
 gcc (ie 3.2.3)? Thanks,
 
 Dara
 
Comment 2 Giovanni Bajo 2003-05-12 11:19:15 UTC
State-Changed-From-To: open->feedback
State-Changed-Why: See Dara's question.
Comment 3 Dara Hazeghi 2003-07-05 16:53:53 UTC
Just a reminder that this bug is waiting for feedback. Would it be possible for you to check whether 
this problem still occurs with gcc 3.3? Thanks,

Dara
Comment 4 minyard 2003-07-08 04:43:09 UTC
Fixed in gcc 3.3.  Thanks.