PR24944, gas doesn't read enough digits when parsing a floating point number
authorAlan Modra <amodra@gmail.com>
Wed, 20 Nov 2019 11:24:07 +0000 (21:54 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 20 Nov 2019 11:29:33 +0000 (21:59 +1030)
PR 24944
* atof-generic.c (atof_generic): Increase decimal guard digits.
* testsuite/gas/i386/fp.s: Add more tests.
* testsuite/gas/i386/fp.d: Update.

gas/ChangeLog
gas/atof-generic.c
gas/testsuite/gas/i386/fp.d
gas/testsuite/gas/i386/fp.s

index d9ad6498efc0dfd8d3da17f6b394e606c77ad64c..91179188f3d2c502c14f8fe015070a91b54332d5 100644 (file)
@@ -1,3 +1,10 @@
+2019-11-20  Alan Modra  <amodra@gmail.com>
+
+       PR 24944
+       * atof-generic.c (atof_generic): Increase decimal guard digits.
+       * testsuite/gas/i386/fp.s: Add more tests.
+       * testsuite/gas/i386/fp.d: Update.
+
 2019-11-18  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * as.c (parse_args): Parse --gdwarf-cie-version option.
index 345ccef2c1c32c7acbf98acca48109f2ae62adcc..8807cc5605276a0b73bbd710fbcb1c8f9076f598 100644 (file)
@@ -347,11 +347,12 @@ atof_generic (/* return pointer to just AFTER number we read.  */
                   - address_of_generic_floating_point_number->low
                   + 1);        /* Number of destination littlenums.  */
 
-      /* Includes guard bits (two littlenums worth) */
-      maximum_useful_digits = (((precision - 2))
-                              * ( (LITTLENUM_NUMBER_OF_BITS))
-                              * 1000000 / 3321928)
-       + 2;                    /* 2 :: guard digits.  */
+      /* precision includes two littlenums worth of guard bits,
+        so this gives us 10 decimal guard digits here.  */
+      maximum_useful_digits = (precision
+                              * LITTLENUM_NUMBER_OF_BITS
+                              * 1000000 / 3321928
+                              + 1);    /* round up.  */
 
       if (number_of_digits_available > maximum_useful_digits)
        {
index a9a9538cd09252269270e6a2659c4cec51184e59..edf79ff999666007324efbb61b8a29ca60ad0f5e 100644 (file)
@@ -4,6 +4,8 @@
 .*:     file format .*
 
 Contents of section .data:
- 0000 00881bcd 4b789ad4 004071a3 79094f93  ....Kx...@q.y.O.
- 0010 0a40789a 5440789a 54400000 00000000  .@x.T@x.T@......
- 0020 e65e1710 20395e3b e65e1710 20395e3b  .\^.. 9\^;.\^.. 9\^;
+ 0000 00881bcd 4b789ad4 004071a3 79094f93  .*
+ 0010 0a40789a 5440789a 54400000 00000000  .*
+ 0020 e65e1710 20395e3b e65e1710 20395e3b  .*
+ 0030 00000000 0000a044 01000000 0000a044  .*
+ 0040 00000000 0000f03f .*
index a1f2b0f0a48428d1745354767ea4854fca8e199d..11a50cf268365d521073e20dfc6431a69ecd1a97 100644 (file)
@@ -15,3 +15,8 @@
 # The assembler used to treat the next value as zero instead of 1e-22.
         .double .0000000000000000000001
         .double 1e-22
+# The assembler used to limit the number of digits too much.
+       .double 37778931862957165903871.0
+       .double 37778931862957165903873.0
+# Ensure we handle a crazy number of digits
+       .double 1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
This page took 0.029197 seconds and 4 git commands to generate.