Re: strtod bugs

2008-04-01 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote: According to Eric Blake on 3/30/2008 4:03 PM: | And just now, I tested cygwin with -O2, and got: | | ../../m4/tests/test-strtod.c:149: assertion failed | ../../m4/tests/test-strtod.c:221: assertion failed | | which looks like rounding errors in computing

Re: strtod bugs

2008-04-01 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 4/1/2008 1:02 AM: | Wow - gnulib's version of strtod really IS inaccurate. The buildbot is | still showing failures, since 5 * pow (10.0, -1) != 0.5. Any suggestions | on how to make this test pass? Would it be

Re: strtod bugs

2008-04-01 Thread Eric Blake
Eric Blake ebb9 at byu.net writes: Done as follows. FLT_EPSILON represents a 2-ulp error for 0.5; Actually, FLT_EPSILON represents a 2-ulp error for 0.5f, and unless FLT_EVAL_METHOD0, it's waaay more than 2-ulp of the double 0.5. I also botched FLT_MIN instead of DBL_MIN, now fixed. --

Re: strtod bugs

2008-04-01 Thread Bruno Haible
Eric Blake wrote: * doc/posix-headers/math.texi (math.h): Document this. It's not only Solaris 8 which lacks it. I'm updating the doc. Also, I prefer not to libel a particular compiler as broken. If we label every compiler or platform which has a bug as broken, not only every system will have

Re: strtod bugs

2008-04-01 Thread Bruno Haible
Eric Blake wrote: * tests/test-math.c (main): Test it. This test fails on IRIX 6.5 with CC=cc -O. The reason is that it inlines the 'd == d' test. Here is the machine code that the compiler generates: .entmain .globl main main:# 0x0 .frame $sp, 0, $31

Re: strtod bugs

2008-04-01 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 4/1/2008 7:05 PM: | While I like that you collected the many instances of the function which | returns a NaN into a single place, I don't like two things here: | | 1) POSIX says that math.h defines the macro NAN, but

Re: strtod bugs

2008-04-01 Thread Bruno Haible
Eric Blake wrote: | 1) POSIX says that math.h defines the macro NAN, but also says that it | expands into a constant expression. We cannot guarantee that. Therefore | is it better to define the macro or not? Well, I did document in doc/posix-functions/math.texi that NAN might not

Re: strtod bugs

2008-04-01 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 4/1/2008 7:45 PM: | Were you planning on backing out the math.in.h changes? | | It depends on your vote... If you say no, then no. Let's leave it in for now: I'm brave enough to make m4 1.4.11 the litmus test. If

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 3/30/2008 6:11 PM: | Find attached the results on a dozen of platforms. Thanks. | | I integrated these test results into test-strtod.c as comments (since we don't | yet have a matrix like in m4/printf.m4), using a

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Eric Blake on 3/31/2008 6:24 AM: | | - You seem to have seen problems on Solaris 8 that I did not see. | What can | | be the reason? Did you use gnulib's signbit and isnan functions? I | used | | the ones from the system, or

Re: strtod bugs

2008-03-31 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] 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

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 3/31/2008 11:24 AM: | | 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

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Eric Blake on 3/31/2008 1:22 PM: | | 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. | | Good catch. Yes,

Re: strtod bugs

2008-03-31 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote: According to Jim Meyering on 3/31/2008 11:24 AM: | | 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)

Re: strtod bugs

2008-03-31 Thread Bruno Haible
Eric Blake wrote: should we raise this as a gcc bug, that when it does constant-folding optimization of signbit at compile-time (signbit(-0.0) = 1), it results in a different value than when the macro is used on a runtime value (signbit(result) = mask off all but the sign bit)? I don't think

Re: strtod bugs

2008-03-31 Thread Bruno Haible
Eric Blake wrote: The problem was that Solaris 8 does not define NAN anywhere, so the test failures I saw in the NaN section of test-strtod.c were because Solaris was correctly parsing NaN, but the test thought that NaN was not possible. So, the '#ifdef NAN' needs to go. It's less portable

Re: strtod bugs

2008-03-31 Thread Bruno Haible
Eric Blake wrote: * tests/test-strtod.c: New file. The file is using C99 syntax; Solaris cc does not grok it. This converts it to C89 syntax. 2008-03-31 Bruno Haible [EMAIL PROTECTED] * tests/test-strtod.c (main): Don't use C99 syntax. --- tests/test-strtod.c.orig2008-04-01

Re: strtod bugs

2008-03-31 Thread Bruno Haible
Eric Blake wrote: Even more thanks! I'm adding the following, which does some more interpretation of your results. Thanks. Somehow now I get slightly different results on OSF/1 4.0. Updated: 2008-03-31 Bruno Haible [EMAIL PROTECTED] * tests/test-strtod.c (main): Update results for

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 3/31/2008 4:04 PM: | Eric Blake wrote: | The problem was that Solaris 8 does not define NAN anywhere, so the | test failures I saw in the NaN section of test-strtod.c were because | Solaris was correctly parsing NaN, but

Re: strtod bugs

2008-03-31 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Eric Blake on 3/30/2008 4:03 PM: | And just now, I tested cygwin with -O2, and got: | | ../../m4/tests/test-strtod.c:149: assertion failed | ../../m4/tests/test-strtod.c:221: assertion failed | | which looks like rounding errors in

Re: strtod bugs

2008-03-30 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote: ... Therefore, I'm asking for opinions - should I apply this patch as is, to Seems fine that you've applied it, except for a new failure in coreutils' running of the gnulib strtod test. E.g., test-strtod.c:544: assertion failed test-strtod.c:592:

Re: strtod bugs

2008-03-30 Thread Jim Meyering
Jim Meyering [EMAIL PROTECTED] wrote: Eric Blake [EMAIL PROTECTED] wrote: ... Therefore, I'm asking for opinions - should I apply this patch as is, to Seems fine that you've applied it, except for a new failure in coreutils' running of the gnulib strtod test. E.g., The buildbot is also

Re: strtod bugs

2008-03-30 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 3/30/2008 7:31 AM: | | The buildbot is also showing a new compile failure: | | http://buildbot.proulx.com:9000/ | | cc1: warnings being treated as errors Thanks for the report; I'm applying this: - -- Don't work too

Re: strtod bugs

2008-03-30 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 3/30/2008 7:28 AM: | Eric Blake [EMAIL PROTECTED] wrote: | ... | Therefore, I'm asking for opinions - should I apply this patch as is, to | | Seems fine that you've applied it, except for a new failure | in coreutils'

Re: strtod bugs

2008-03-30 Thread Jim Meyering
Eric Blake [EMAIL PROTECTED] wrote: According to Jim Meyering on 3/30/2008 7:28 AM: | Eric Blake [EMAIL PROTECTED] wrote: | ... | Therefore, I'm asking for opinions - should I apply this patch as is, to | | Seems fine that you've applied it, except for a new failure | in coreutils' running

Re: strtod bugs

2008-03-30 Thread Bruno Haible
Hi Eric, Of all the systems I tried, I did not find a single one that was fully C99 compliant. I'd like to document the flaws across more platforms. Do you have a set of test programs, one snippet for each bug you found so far, that I could run on a variety of systems? I could try to extract

Re: strtod bugs

2008-03-30 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 3/30/2008 2:44 PM: | Hi Eric, | | Of all the | systems I tried, I did not find a single one that was fully C99 compliant. | | I'd like to document the flaws across more platforms. Do you have a set of | test programs, one

Re: strtod bugs

2008-03-30 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Jim Meyering on 3/30/2008 8:49 AM: | | In my copy of test-strtod.c, they're all comparing sign bits: | | ASSERT (signbit (result1) != signbit (result2)); The default value of NaN (both sign bit and other bits) are enough of a

Re: strtod bugs

2008-03-30 Thread Eric Blake
-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

Re: strtod bugs

2008-03-30 Thread Bruno Haible
Eric Blake wrote: test-strtod.c is all I had; but I intentionally made it catch all errors rather than aborting on the first Ah, I see. Sorry, I had not seen this detail. Find attached the results on a dozen of platforms. I integrated these test results into test-strtod.c as comments (since

Re: strtod bugs

2008-03-30 Thread Bruno Haible
Oops, the shown patch in the last mail was incomplete. See http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=b442459322dbef0bcb547770565b05724e98b47d for the full patch. (Sorry, a 'git' pitfall. I had used 'git add' on one file and not on the other. What is the command to get the union of

Re: strtod bugs

2008-03-30 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Bruno Haible on 3/30/2008 6:18 PM: | Oops, the shown patch in the last mail was incomplete. See | http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=b442459322dbef0bcb547770565b05724e98b47d | for the full patch. | | (Sorry, a

Re: strtod bugs

2008-03-29 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Eric Blake on 3/29/2008 3:29 PM: | Therefore, I'm asking for opinions - should I apply this patch as is, to | at least guarantee 'inf' and 'nan' parsing on all platforms, even though | it can cause regressions on the accuracy of the