GAS IEEE FP bug

Gary Thomas gdt@linuxppc.org
Fri Mar 5 23:12:00 GMT 1999


There is an error in all versions of GAS which use IEEE floating point.
The version I was testing is: GNU assembler version 2.9.1

This constant is improperly assembled:
   9 0020 00000000              .float 0d1.40129846432481707092e-45
The correct value (Big Endian) would be
   9 0020 00000001              .float 0d1.40129846432481707092e-45
The correct value (Little Endian) would be
   9 0020 01000000              .float 0d1.40129846432481707092e-45

Note: this is the smallest possible IEEE unnormalized "float" value.

A simple patch for this (seems to work at least) is:

--- binutils-2.9.1/gas/config/atof-ieee.c~      Fri May  1 16:44:33 1998
+++ binutils-2.9.1/gas/config/atof-ieee.c       Sat Mar  6 06:57:08 1999
@@ -444,6 +444,8 @@
       unget_bits (1);
       num_bits = -exponent_4;
       prec_bits = LITTLENUM_NUMBER_OF_BITS * precision - (exponent_bits + 1 + num_bits);
+      // There is 1 more bit of precision here (hidden)
+      prec_bits += 1;
 #ifdef TC_I386
       if (precision == X_PRECISION && exponent_bits == 15)
        {





More information about the Gcc mailing list