[uClibc] Re: Is there a workaround for this floating point bug?

Erik Andersen andersen at codepoet.org
Sun Aug 10 07:57:49 UTC 2003


On Sat Aug 09, 2003 at 11:17:51PM -0600, Erik wrote:
> On Sat Aug 09, 2003 at 09:32:42PM -0700, David Wuertele wrote:
> > Would you mind testing with -msoft-float?
> 
> Ok.  Will do, after I recompile uClibc with UCLIBC_HAS_SOFT_FLOAT
> enabled, which is gonna take a little while.  I just started
> uClibc recompiling.  Did I mention how slow my mips test box is?

I needed to make one more change to your test app...

    double thisdub = (double)0.1;
    if ((thisdub - (double)0.1) > 0.000001) {
        fprintf (stderr, "doubles are hosed!\n");
        return 0;
    }

since testing if doubles are equal is always a bit dangerous.
Anyway, with that I get:

    $ ./test 
    if nan and nan don't both equal 0.100000,suspect fprintf
    if nan and nan aren't close to 120, suspect float operations

which is rather interesting.  Inside uClibc/libc/stdio/printf.c:
when have this call sequence:

    main()
    fprintf() in printf.c:1444
    vfprintf() at printf.c:3169
    _do_one_spec() at printf.c:2781
    _ppfs_setargs() at printf.c:671

where it recognizes it is supposed to fetch a double, but all
that comes out is a 'nan' instead...  Very wierd.

If I had to guess (which I do at this point), I would hazzard a
guess that the va_copy() in _ppfs_prepargs() is messing things up
and not properly dealing with soft-float, suggesting this is a
gcc problem.  This is going to take a bit more digging to be
certain exactly what is going wrong.

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the uClibc mailing list