This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
PR32083 - Use correct sign for -Inf in real.c's mpfr_from_real
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Sat, 26 May 2007 23:55:39 +0200
- Subject: PR32083 - Use correct sign for -Inf in real.c's mpfr_from_real
:ADDPATCH middle-end:
This should be obvious. REAL_VALUE_TYPE's sign is one for negative
numbers and zero for positive numbers.
mpfr_set_inf is positive for sign >= 0, and negative for sign < 0.
Build on x86_64-unknown-linux-gnu and checked via check-gcc and
check-gfortran with no new failures.
(failing are gcc.c-torture/execute/mayalias-2.c (ICE),
gcc.c-torture/execute/mayalias-3.c (ICE) and gcc.dg/cpp/Wmissingdirs.c)
Ok for the trunk?
Tobias
2007-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/32083
* real.c (mpfr_from_real): Fix sign of -Inf.
2007-05-26 Tobias Burnus <burnus@net-b.de>
PR fortran/32083
* gfortran.dg/transfer_simplify_3.f90: New.
Index: real.c
===================================================================
--- real.c (revision 125096)
+++ real.c (working copy)
@@ -4746,7 +4746,7 @@ mpfr_from_real (mpfr_ptr m, const REAL_V
/* Take care of Infinity and NaN. */
if (r->cl == rvc_inf)
{
- mpfr_set_inf (m, r->sign);
+ mpfr_set_inf (m, r->sign == 1 ? -1 : 1);
return;
}
Index: testsuite/gfortran.dg/transfer_simplify_3.f90
===================================================================
--- testsuite/gfortran.dg/transfer_simplify_3.f90 (revision 0)
+++ testsuite/gfortran.dg/transfer_simplify_3.f90 (revision 0)
@@ -0,0 +1,53 @@
+! { dg-do run }
+! { dg-option "-fno-range-check" }
+! PR fortran/32083
+!
+! Test transfers of +Inf and -Inf
+! Testcase contributed by Jos de Kloe <kloedej@knmi.nl>
+!
+
+PROGRAM TestInfinite
+ IMPLICIT NONE
+ integer, parameter :: i8_ = Selected_Int_Kind(18) ! = integer*8
+ integer, parameter :: r8_ = Selected_Real_Kind(15,307) ! = real*8
+
+ integer(i8_), parameter :: bit_pattern_PosInf_i8_p = 9218868437227405312_i8_
+ integer(i8_), parameter :: bit_pattern_NegInf_i8_p = -4503599627370496_i8_
+
+ integer(i8_) :: bit_pattern_PosInf_i8 = 9218868437227405312_i8_
+ integer(i8_) :: bit_pattern_NegInf_i8 = -4503599627370496_i8_
+
+ integer(i8_) :: bit_pattern_PosInf_i8_hex
+ integer(i8_) :: bit_pattern_NegInf_i8_hex
+
+ integer(i8_) :: i
+ real(r8_) :: r
+
+ data bit_pattern_PosInf_i8_hex /z'7FF0000000000000'/
+ !data bit_pattern_NegInf_i8_hex /z'FFF0000000000000'/
+ ! not portable, replaced by:
+ bit_pattern_NegInf_i8_hex = ibset(bit_pattern_PosInf_i8_hex,63)
+
+ if (bit_pattern_NegInf_i8_hex /= bit_pattern_NegInf_i8) call abort()
+ if (bit_pattern_PosInf_i8_hex /= bit_pattern_PosInf_i8) call abort()
+
+ r = transfer(bit_pattern_PosInf_i8,r)
+ if (r /= 1.0_r8_/0.0_r8_) call abort()
+ i = transfer(r,i)
+ if (bit_pattern_PosInf_i8 /= i) call abort()
+
+ r = transfer(bit_pattern_NegInf_i8,r)
+ if (r /= -1.0_r8_/0.0_r8_) call abort()
+ i = transfer(r,i)
+ if (bit_pattern_NegInf_i8 /= i) call abort()
+
+ r = transfer(bit_pattern_PosInf_i8_p,r)
+ if (r /= 1.0_r8_/0.0_r8_) call abort()
+ i = transfer(r,i)
+ if (bit_pattern_PosInf_i8_p /= i) call abort()
+
+ r = transfer(bit_pattern_NegInf_i8_p,r)
+ if (r /= -1.0_r8_/0.0_r8_) call abort()
+ i = transfer(r,i)
+ if (bit_pattern_NegInf_i8_p /= i) call abort()
+END PROGRAM TestInfinite