public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anlauf at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/109186] nearest(huge(x),-1.0_kind(x)) half of correct value
Date: Sun, 19 Mar 2023 19:58:48 +0000	[thread overview]
Message-ID: <bug-109186-4-JMdeP2G1MG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109186-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109186

--- Comment #4 from anlauf at gcc dot gnu.org ---
The following patch fixes this:

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 20ea38e0007..35ae637a483 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -6114,7 +6112,7 @@ gfc_simplify_nearest (gfc_expr *x, gfc_expr *s)
   kind = gfc_validate_kind (BT_REAL, x->ts.kind, 0);
   mpfr_set_emin ((mpfr_exp_t) gfc_real_kinds[kind].min_exponent -
                mpfr_get_prec(result->value.real) + 1);
-  mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[kind].max_exponent - 1);
+  mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[kind].max_exponent);
   mpfr_check_range (result->value.real, 0, MPFR_RNDU);

   if (mpfr_sgn (s->value.real) > 0)

The above code was apparently introduced with r0-84566-gb6f63e898498e6

  parent reply	other threads:[~2023-03-19 19:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19  1:46 [Bug fortran/109186] New: " john.harper at vuw dot ac.nz
2023-03-19  5:06 ` [Bug fortran/109186] " jvdelisle at gcc dot gnu.org
2023-03-19  8:47 ` john.harper at vuw dot ac.nz
2023-03-19 19:30 ` anlauf at gcc dot gnu.org
2023-03-19 19:58 ` anlauf at gcc dot gnu.org [this message]
2023-03-19 20:45 ` anlauf at gcc dot gnu.org
2023-03-20 17:46 ` cvs-commit at gcc dot gnu.org
2023-03-22 18:00 ` cvs-commit at gcc dot gnu.org
2023-03-24 18:41 ` cvs-commit at gcc dot gnu.org
2023-03-24 18:44 ` cvs-commit at gcc dot gnu.org
2023-03-24 18:46 ` anlauf at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109186-4-JMdeP2G1MG@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).