diff mbox

[pushed,MPFR] Fix regression on 32-bit host systems

Message ID 20171211142908.E5606D80340@oc3748833570.ibm.com
State New
Headers show

Commit Message

Ulrich Weigand Dec. 11, 2017, 2:29 p.m. UTC
Hello,

when converting parts of the mantissa to MPFR, we need to make sure to do
an *unsigned* conversion.  Since we convert at most 32 bits at a time,
stored in an unsigned long, this doesn't matter on systems where "long"
is larger than 32 bits.  But on systems where it is 32 bits, we can get
conversion errors.

Tested on x86_64-linux and i686-linux, pushed to mainline.

Bye,
Ulrich


gdb/ChangeLog
2017-12-11  Ulrich Weigand  <uweigand@de.ibm.com>

	* target-float.c (mpfr_float_ops::from_target): Use mpfr_set_ui
	instead of mpfr_set_si to convert mantissa bits.
diff mbox

Patch

diff --git a/gdb/target-float.c b/gdb/target-float.c
index b40b641..9b14609 100644
--- a/gdb/target-float.c
+++ b/gdb/target-float.c
@@ -1312,7 +1312,7 @@  mpfr_float_ops::from_target (const struct floatformat *fmt,
 
       mant = get_field (from, order, fmt->totalsize, mant_off, mant_bits);
 
-      mpfr_set_si (tmp.val, mant, MPFR_RNDN);
+      mpfr_set_ui (tmp.val, mant, MPFR_RNDN);
       mpfr_mul_2si (tmp.val, tmp.val, exponent - mant_bits, MPFR_RNDN);
       mpfr_add (to.val, to.val, tmp.val, MPFR_RNDN);
       exponent -= mant_bits;