This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [MPFR] Fix regression on 32-bit host systems


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2f9e7ecc1f02bfe5da83c38cf356ea96d428c6d

commit f2f9e7ecc1f02bfe5da83c38cf356ea96d428c6d
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Date:   Mon Dec 11 15:26:26 2017 +0100

    [MPFR] Fix regression on 32-bit host systems
    
    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.
    
    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:
---
 gdb/ChangeLog      | 5 +++++
 gdb/target-float.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1c67e41..b3c5b97 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+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.
+
 2017-12-11  Xavier Roirand <roirand@adacore.com>
 	    Joel Brobecker  <brobecker@adacore.com>
 
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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]