From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6064 invoked by alias); 4 Feb 2002 19:07:13 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 4525 invoked by uid 71); 4 Feb 2002 19:06:24 -0000 Resent-Date: 4 Feb 2002 19:06:23 -0000 Resent-Message-ID: <20020204190623.4524.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, minyard@acm.org Received:(qmail 1296 invoked by uid 61); 4 Feb 2002 17:19:49 -0000 Message-Id:<20020204171949.1294.qmail@sources.redhat.com> Date: Mon, 04 Feb 2002 11:07:00 -0000 From: minyard@acm.org Reply-To: minyard@acm.org To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: ada/5590: Float'Image unreliable with zero, Is_Negative intrisic to blame X-SW-Source: 2002-02/txt/msg00084.txt.bz2 List-Id: >Number: 5590 >Category: ada >Synopsis: Float'Image unreliable with zero, Is_Negative intrisic to blame >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Feb 04 11:06:22 PST 2002 >Closed-Date: >Last-Modified: >Originator: Corey Minyard >Release: Current gcc 3.1 tree >Organization: >Environment: Linux/PPC >Description: 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. >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 >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="tester" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="tester" CnBhY2thZ2UgU3lzdGVtLlRlc3RlcjNfWCBpcwoKICAgZnVuY3Rpb24gSXNfTmVnYXRpdmUgKFYg OiBMb25nX0xvbmdfRmxvYXQpIHJldHVybiBCb29sZWFuOwogICBwcmFnbWEgSW1wb3J0IChJbnRy aW5zaWMsIElzX05lZ2F0aXZlKTsKCmVuZCBTeXN0ZW0uVGVzdGVyM19YOwoKd2l0aCBBZGEuVGV4 dF9JTzsKdXNlIEFkYS5UZXh0X0lPOwp3aXRoIFN5c3RlbS5UZXN0ZXIzX1g7IHVzZSBTeXN0ZW0u VGVzdGVyM19YOwoKcHJvY2VkdXJlIFRlc3RlcjMgaXMKICAgdmFsMiA6IEZsb2F0IDo9IDAuMDsK ICAgVmFsIDogU3RyaW5nIDo9IEZsb2F0J0ltYWdlKFZhbDIpOwogICBwcm9jZWR1cmUgWDEoWCA6 IEZsb2F0KSBpcwogICBiZWdpbgogICAgICBpZiAoWCA8IDAuMCkgdGhlbgogICAgICAgICBQdXRf TGluZSgiSXMgTmVnYXRpdmUgMSIpOwogICAgICBlbmQgaWY7CiAgICAgIGlmIChJc19OZWdhdGl2 ZShMb25nX0xvbmdfRmxvYXQoWCkpKSB0aGVuCiAgICAgICAgIFB1dF9MaW5lKCJJcyBOZWdhdGl2 ZSAyIik7CiAgICAgIGVuZCBpZjsKICAgZW5kIFgxOwpiZWdpbgogICBQdXRfTGluZSgiVmFsOiAn IiAmIFZhbCAmICInIik7CiAgIFB1dF9MaW5lKCJWYWw6ICciICYgRmxvYXQnSW1hZ2UoMC4wKSAm ICInIik7CiAgIFB1dF9MaW5lKCJDb25zdGFudCIpOwogICBYMSgwLjApOwogICBQdXRfTGluZSgi VmFyaWFibGUiKTsKICAgWDEoVmFsMik7CmVuZCBUZXN0ZXIzOwo=