[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strtod bugs
From: |
Jim Meyering |
Subject: |
Re: strtod bugs |
Date: |
Mon, 31 Mar 2008 19:24:52 +0200 |
Eric Blake <address@hidden> wrote:
> According to Jim Meyering on 3/30/2008 8:49 AM:
...
> Ahh. That makes sense - I was going off the line numbers in gnulib, not
> in my bootstrapped copy of coreutils. Maybe the same bootstrap process
> that adds those two lines should add a third line?
> #line 1
Yes, I'll do that. Thanks.
> | When I run the tests on a 32-bit system with ubuntu's
> | 2.7-9ubuntu2, I get even more failures:
> |
> | PASS: test-string
> | test-strtod.c:285: assertion failed
> | test-strtod.c:371: assertion failed
>
> Parsing "-0" as 0.0 rather than -0.0 - definite bug. The buildbot is
> showing the same failure. But the buildbot also shows:
> checking whether strtod obeys C99... no
> -e 's|@''REPLACE_STRTOD''@|1|g' \
>
> So, just to be clear, are we seeing any platforms that return positive 0
> on "-0" but which are not using the replacement function? However, I
> thought strtod.m4 already caught that.
Actually, strtod is doing the right thing: it produces -0,
with both the libc version and the gnulib-supplied function.
The trouble is that signbit(result) returns INT_MIN,
while signbit(-0.0) returns 1. Both seem to be allowed, so
how about this change? It solves the problem for me.
>From 909b7d765b7d08dd350928bf71911afa6983113a Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 31 Mar 2008 19:22:06 +0200
Subject: [PATCH] Don't compare actual signbit return values.
* tests/test-strtod.c (main): Rather, compare only their
zero/non-zero nature.
Signed-off-by: Jim Meyering <address@hidden>
---
ChangeLog | 6 ++++++
tests/test-strtod.c | 16 ++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6c36fed..5f4fa70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-31 Jim Meyering <address@hidden>
+
+ Don't compare actual signbit return values.
+ * tests/test-strtod.c (main): Rather, compare only their
+ zero/non-zero nature.
+
2008-03-31 Eric Blake <address@hidden>
More strtod documentation.
diff --git a/tests/test-strtod.c b/tests/test-strtod.c
index d1797d8..f573b1a 100644
--- a/tests/test-strtod.c
+++ b/tests/test-strtod.c
@@ -280,7 +280,7 @@ main ()
char *ptr;
double result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (signbit (result) == signbit (-0.0)); /* IRIX 6.5 */
+ ASSERT (!!signbit (result) == !!signbit (-(double)0.0)); /* IRIX 6.5 */
ASSERT (ptr == input + 2);
ASSERT (errno == 0);
}
@@ -366,7 +366,7 @@ main ()
char *ptr;
double result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (signbit (result) == signbit (-0.0)); /* MacOS X 10.3, FreeBSD 6.2,
IRIX 6.5 */
+ ASSERT (!!signbit (result) == !!signbit (-0.0)); /* MacOS X 10.3, FreeBSD
6.2, IRIX 6.5 */
ASSERT (ptr == input + 2); /* glibc-2.3.6, MacOS X 10.3, FreeBSD
6.2 */
ASSERT (errno == 0);
}
@@ -480,7 +480,7 @@ main ()
0 on negative underflow, even though quality of implementation
demands preserving the sign. Disable this test until fixed
glibc is more prevalent. */
- ASSERT (signbit (result) == signbit (-0.0)); /* glibc-2.3.6, mingw */
+ ASSERT (!!signbit (result) == !!signbit (-0.0)); /* glibc-2.3.6, mingw */
#endif
ASSERT (ptr == input + 10);
ASSERT (errno == ERANGE);
@@ -548,7 +548,7 @@ main ()
# if 0
/* Sign bits of NaN is a portability sticking point, not worth
worrying about. */
- ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5,
OSF/1 5.1, mingw */
+ ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX
6.5, OSF/1 5.1, mingw */
# endif
ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1,
Solaris 2.5.1, mingw */
ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, IRIX 6.5, OSF/1 5.1,
Solaris 2.5.1, mingw */
@@ -573,7 +573,7 @@ main ()
#ifdef NAN
ASSERT (isnan (result1)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5,
OSF/1 5.1, mingw */
ASSERT (isnan (result2)); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5,
OSF/1 5.1, mingw */
- ASSERT (signbit (result1) == signbit (result2));
+ ASSERT (!!signbit (result1) == !!signbit (result2));
ASSERT (ptr1 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5,
OSF/1 5.1, Solaris 2.5.1, mingw */
ASSERT (ptr2 == input + 4); /* OpenBSD 4.0, HP-UX 11.11, IRIX 6.5,
OSF/1 5.1, Solaris 2.5.1, mingw */
ASSERT (errno == 0);
@@ -600,7 +600,7 @@ main ()
# if 0
/* Sign bits of NaN is a portability sticking point, not worth
worrying about. */
- ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5,
OSF/1 5.1, mingw */
+ ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX
6.5, OSF/1 5.1, mingw */
# endif
ASSERT (ptr1 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD
6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */
ASSERT (ptr2 == input + 6); /* glibc-2.3.6, MacOS X 10.3, FreeBSD
6.2, OpenBSD 4.0, AIX 5.1, HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */
@@ -647,7 +647,7 @@ main ()
# if 0
/* Sign bits of NaN is a portability sticking point, not worth
worrying about. */
- ASSERT (signbit (result1) != signbit (result2)); /* glibc-2.3.6, IRIX 6.5,
OSF/1 5.1, mingw */
+ ASSERT (!!signbit (result1) != !!signbit (result2)); /* glibc-2.3.6, IRIX
6.5, OSF/1 5.1, mingw */
# endif
ASSERT (ptr1 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1,
HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */
ASSERT (ptr2 == input + 7); /* glibc-2.3.6, OpenBSD 4.0, AIX 5.1,
HP-UX 11.11, IRIX 6.5, OSF/1 5.1, mingw */
@@ -829,7 +829,7 @@ main ()
input[m] = '\0';
result = strtod (input, &ptr);
ASSERT (result == 0.0);
- ASSERT (signbit (result) == signbit (-0.0)); /* IRIX 6.5 */
+ ASSERT (!!signbit (result) == !!signbit (-0.0)); /* IRIX 6.5 */
ASSERT (ptr == input + m);
ASSERT (errno == 0);
}
--
1.5.5.rc1.13.g79388
- strtod bugs, Eric Blake, 2008/03/29
- Re: strtod bugs, Eric Blake, 2008/03/29
- Re: strtod bugs, Jim Meyering, 2008/03/30
- Re: strtod bugs, Jim Meyering, 2008/03/30
- Re: strtod bugs, Eric Blake, 2008/03/30
- Re: strtod bugs, Jim Meyering, 2008/03/30
- Re: strtod bugs, Eric Blake, 2008/03/30
- Re: strtod bugs, Eric Blake, 2008/03/30
- Re: strtod bugs,
Jim Meyering <=
- Re: strtod bugs, Eric Blake, 2008/03/31
- Re: strtod bugs, Eric Blake, 2008/03/31
- Re: strtod bugs, Bruno Haible, 2008/03/31
- Re: strtod bugs, Jim Meyering, 2008/03/31
Re: strtod bugs, Bruno Haible, 2008/03/30