From ff7097f21e538fc38bf22e30acfbea74433fb2b4 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 14 Jul 2015 21:44:46 +0000 Subject: [PATCH] simplify.c (gfc_simplify_floor): Set precision of temporary to that of arg. 2015-07-14 Steven G. Kargl * simplify.c (gfc_simplify_floor): Set precision of temporary to that of arg. 2015-07-14 Steven G. Kargl gfortran.dg/pr66864.f90: New test. From-SVN: r225790 --- gcc/fortran/ChangeLog | 5 +++++ gcc/fortran/simplify.c | 4 +--- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/pr66864.f90 | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr66864.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0a2734b6695..b13f67f75fb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-07-14 Steven G. Kargl + + * simplify.c (gfc_simplify_floor): Set precision of temporary to + that of arg. + 2015-07-13 Andre Vehreschild PR fortran/64589 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index bc3ec3f8a60..3fb98873709 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -2351,9 +2351,7 @@ gfc_simplify_floor (gfc_expr *e, gfc_expr *k) if (e->expr_type != EXPR_CONSTANT) return NULL; - gfc_set_model_kind (kind); - - mpfr_init (floor); + mpfr_init2 (floor, mpfr_get_prec (e->value.real)); mpfr_floor (floor, e->value.real); result = gfc_get_constant_expr (BT_INTEGER, kind, &e->where); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 45df0cc0095..801e46285a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-07-14 Steven G. Kargl + + gfortran.dg/pr66864.f90: New test. + 2015-07-14 Vladimir Makarov PR rtl-optimization/66626 diff --git a/gcc/testsuite/gfortran.dg/pr66864.f90 b/gcc/testsuite/gfortran.dg/pr66864.f90 new file mode 100644 index 00000000000..ebea99b3892 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr66864.f90 @@ -0,0 +1,16 @@ +! { dg-do run } +! PR fortran/66864 +! +program t + implicit none + real(8) x + x = 2.0d0**26.5d0 + if (floor(x) /= 94906265) call abort + if (floor(2.0d0**26.5d0)/= 94906265) call abort + x = 777666555.6d0 + if (floor(x) /= 777666555) call abort + if (floor(777666555.6d0) /= 777666555) call abort + x = 2000111222.6d0 + if (floor(x) /= 2000111222) call abort + if (floor(2000111222.6d0) /= 2000111222) call abort +end program t -- 2.30.2