This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double
- From: Julian Brown <julian at codesourcery dot com>
- To: binutils at sources dot redhat dot com
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, DJ Delorie <dj at redhat dot com>, Paul Brook <paul at codesourcery dot com>
- Date: Mon, 24 Apr 2006 19:22:47 +0100
- Subject: [PATCH, libiberty] Fix (biased) exponent = 0 case in floatformat_to_double
Hi,
This patch fixes a case in floatformat_to_double, as used in binutils
for disassembling floats for m68k (and soon ARM also). The failure mode
was as follows: the exponent was tested for zero after biasing, which is
true for floating point values 1.0 <= value < 2.0. Such values took a
code path intended for denormals, with the effect of causing them to
always produce the value 1.0 (or, perhaps, very close to 1.0).
This patch only processes values as denormal when special_exponent is true.
Tested with "make check" on CSL's current binutils branch, with targets
arm-none-eabi and --enable-targets=all (the ARM version includes a new
testcase which exercises some floating-point values).
The patch applies cleanly on GCC head's libiberty too, though I've not
explicitly tested it there. I suspect it'll also apply on binutils head.
OK to apply on src and gcc head, or is there any more testing I should do?
Cheers,
Julian
ChangeLog (libiberty):
* floatformat.c (floatformat_to_double): Fix (biased) exponent=0
case.
Index: floatformat.c
===================================================================
RCS file: /cvs/src/src/libiberty/floatformat.c,v
retrieving revision 1.19
diff -c -p -r1.19 floatformat.c
*** floatformat.c 12 Feb 2006 15:54:25 -0000 1.19
--- floatformat.c 24 Apr 2006 17:47:42 -0000
*************** floatformat_to_double (const struct floa
*** 394,400 ****
/* Handle denormalized numbers. FIXME: What should we do for
non-IEEE formats? */
! if (exponent == 0 && mant != 0)
dto += ldexp ((double)mant,
(- fmt->exp_bias
- mant_bits
--- 394,400 ----
/* Handle denormalized numbers. FIXME: What should we do for
non-IEEE formats? */
! if (special_exponent && exponent == 0 && mant != 0)
dto += ldexp ((double)mant,
(- fmt->exp_bias
- mant_bits