ada/5590: Float'Image unreliable with zero, Is_Negative intrisic to blame
minyard@acm.org
minyard@acm.org
Mon Feb 4 11:07:00 GMT 2002
>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 <minyard@acm.org>
>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=
More information about the Gcc-bugs
mailing list