public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libfortran/52413] Incorrect behavior of FRACTION when applied to a constant Date: Tue, 28 Feb 2012 16:13:00 -0000 [thread overview] Message-ID: <bug-52413-4-6jB0eT27Tt@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52413-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52413 kargl at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P4 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2012-02-28 CC| |kargl at gcc dot gnu.org AssignedTo|unassigned at gcc dot |kargl at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 Known to fail| |4.2.5, 4.3.6, 4.4.7, 4.5.4, | |4.6.3, 4.7.0 --- Comment #1 from kargl at gcc dot gnu.org 2012-02-28 16:11:10 UTC --- Confirmed. This fails on all versions of gfortran 4.2 and up. I don't have a 4.1 version for testing. I have a patch, but as this is not a regression, I will not apply it until after 4.7.0 is released. Tentative patch. Not regression tested, yet. Index: simplify.c =================================================================== --- simplify.c (revision 184485) +++ simplify.c (working copy) @@ -2331,35 +2331,16 @@ gfc_expr * gfc_simplify_fraction (gfc_expr *x) { gfc_expr *result; - mpfr_t absv, exp, pow2; + mpfr_exp_t e; if (x->expr_type != EXPR_CONSTANT) return NULL; result = gfc_get_constant_expr (BT_REAL, x->ts.kind, &x->where); - if (mpfr_sgn (x->value.real) == 0) - { - mpfr_set_ui (result->value.real, 0, GFC_RND_MODE); - return result; - } - gfc_set_model_kind (x->ts.kind); - mpfr_init (exp); - mpfr_init (absv); - mpfr_init (pow2); - - mpfr_abs (absv, x->value.real, GFC_RND_MODE); - mpfr_log2 (exp, absv, GFC_RND_MODE); - - mpfr_trunc (exp, exp); - mpfr_add_ui (exp, exp, 1, GFC_RND_MODE); - - mpfr_ui_pow (pow2, 2, exp, GFC_RND_MODE); - - mpfr_div (result->value.real, absv, pow2, GFC_RND_MODE); - mpfr_clears (exp, absv, pow2, NULL); + mpfr_frexp (&e, result->value.real, x->value.real, GFC_RND_MODE); return range_check (result, "FRACTION"); }
next prev parent reply other threads:[~2012-02-28 16:12 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-28 9:39 [Bug libfortran/52413] New: " frouet at enseeiht dot fr 2012-02-28 16:13 ` kargl at gcc dot gnu.org [this message] 2012-02-28 20:50 ` [Bug libfortran/52413] " anlauf at gmx dot de 2013-06-22 12:58 ` [Bug fortran/52413] " dominiq at lps dot ens.fr 2013-06-22 15:31 ` sgk at troutmask dot apl.washington.edu 2013-06-23 12:29 ` fxcoudert at gcc dot gnu.org 2013-06-23 12:30 ` fxcoudert at gcc dot gnu.org 2013-06-23 13:15 ` dominiq at lps dot ens.fr 2013-06-23 14:11 ` fxcoudert at gcc dot gnu.org 2013-06-23 15:35 ` dominiq at lps dot ens.fr 2013-06-23 15:36 ` dominiq at lps dot ens.fr 2013-06-23 15:43 ` fxcoudert at gcc dot gnu.org 2013-06-23 16:10 ` dominiq at lps dot ens.fr 2013-06-24 8:45 ` burnus at gcc dot gnu.org 2013-06-24 8:45 ` burnus 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-52413-4-6jB0eT27Tt@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: linkBe 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).