bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strtod bugs


From: Eric Blake
Subject: Re: strtod bugs
Date: Sun, 30 Mar 2008 16:42:33 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 3/30/2008 4:03 PM:
| I'm wondering if it is a gcc -O2 bug?  I'm not quite sure what
| to do here, without access to a machine with those failures.  Can you step
| through the replacement function with a debugger?

Or maybe it's a signbit() bug?  I noticed that test-signbit.c neglects to
test 0.0 and -0.0.  So I'm committing this.  The test tries to be portable
to platforms that lack -0.0 (although these days where IEEE format is
prevalent, I'm not sure of any such machine).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkfwF1kACgkQ84KuGfSFAYCLeACgysiXVBZLwmYwDuA1XJ0H6nZR
ZgUAnj5OdKIc2SfTG34XMyMAcjsMvYrT
=yyNg
-----END PGP SIGNATURE-----
>From 089e636f5322e06f093f03d7da11a05dbc022e4f Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Sun, 30 Mar 2008 16:40:35 -0600
Subject: [PATCH] Test signbit behavior on zeros.

* tests/test-signbit.c (test_signbitf): Add tests for zero.
(test_signbitd, test_signbitl): Likewise.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog            |    4 ++++
 tests/test-signbit.c |   20 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 982e035..932f2e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-03-30  Eric Blake  <address@hidden>
 
+       Test signbit behavior on zeros.
+       * tests/test-signbit.c (test_signbitf): Add tests for zero.
+       (test_signbitd, test_signbitl): Likewise.
+
        More strtod touchups.
        * tests/test-strtod.c (main): Ignore tests for signbit on NaN, and
        sign of negative underflow, for now.  Use .5, not .1.
diff --git a/tests/test-signbit.c b/tests/test-signbit.c
index 9cc65e3..3e01859 100644
--- a/tests/test-signbit.c
+++ b/tests/test-signbit.c
@@ -1,5 +1,5 @@
 /* Test of signbit() substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -49,6 +49,12 @@ test_signbitf ()
   ASSERT (signbit (-2.718f));
   ASSERT (signbit (-2.718e30f));
   ASSERT (signbit (-2.718e-30f));
+  /* Zeros.  */
+  ASSERT (!signbit (0.0f));
+  if (1.0f / -zerof < 0)
+    ASSERT (signbit (-0.0f));
+  else
+    ASSERT (!signbit (-0.0f));
   /* Infinite values.  */
   ASSERT (!signbit (1.0f / 0.0f));
   ASSERT (signbit (-1.0f / 0.0f));
@@ -88,6 +94,12 @@ test_signbitd ()
   ASSERT (signbit (-2.718));
   ASSERT (signbit (-2.718e30));
   ASSERT (signbit (-2.718e-30));
+  /* Zeros.  */
+  ASSERT (!signbit (0.0));
+  if (1.0 / -zerod < 0)
+    ASSERT (signbit (-0.0));
+  else
+    ASSERT (!signbit (-0.0));
   /* Infinite values.  */
   ASSERT (!signbit (1.0 / 0.0));
   ASSERT (signbit (-1.0 / 0.0));
@@ -125,6 +137,12 @@ test_signbitl ()
   ASSERT (signbit (-2.718L));
   ASSERT (signbit (-2.718e30L));
   ASSERT (signbit (-2.718e-30L));
+  /* Zeros.  */
+  ASSERT (!signbit (0.0L));
+  if (1.0L / -zerol < 0)
+    ASSERT (signbit (-0.0L));
+  else
+    ASSERT (!signbit (-0.0L));
   /* Infinite values.  */
   ASSERT (!signbit (1.0L / 0.0L));
   ASSERT (signbit (-1.0L / 0.0L));
-- 
1.5.4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]