[gnu.utils.bug] Bug fix for gas 1.34 atof

ghfeil@white.toronto.edu (Georg Feil) (12/01/89)

Here is the fix for a bug in gas 1.34 that I reported several weeks ago
but was too lazy to go after. As I suspected at that time, it turned out to
be a nasty one (~ 6 hour bug hunt).

The problem involves the ascii to floating-point conversion routines
atof-generic.c and flonum-mult.c when given numbers with excess trailing
zeroes. Here is a test file that demonstrates the bug:

--------------------- bad.s --------------------
.data
        .double 0r4.50359962737049600000e+15
------------------------------------------------


Here is a similar file that assembles correctly:

--------------------- good.s --------------------
.data
        .double 0r4.503599627370496e+15
------------------------------------------------

Compare the binary output from assembling these two input files, and you
should find that it differs. Closer inspection will show loss of precision
in the 'bad.s' case.

There are two patches, as follows:

-------------------- diff old.flonum-mult.c flonum-mult.c -----------
146c146
<       if (significant)
---
>       if (significant || P < 0)
---------------------------------------------------------------------


------------------- diff old.atof-generic.c atof-generic.c ---------
270,271c270,271
<                  )            /* Number of destination littlenums. */
<       + 2;                    /* + 2 :: guard bits :: excess precision */
---
>                  );           /* Number of destination littlenums. Should
>                               /* already include guard bits (2 littlenums) */
---------------------------------------------------------------------


Georg.
-- 
Georg Feil                                            "The roof is leaking
ghfeil@white.toronto.edu                               and the wind is howling"
...if that doesn't work try one of:
{uunet,pyramid,watmath,utzoo}!utcsri!white!ghfeil
ghfeil%white.toronto.edu@relay.cs.net     (ARPA)