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/104848] ICE in simplify_intrinsic_op, at fortran/expr.cc:1305
Date: Wed, 19 Oct 2022 19:18:17 +0000	[thread overview]
Message-ID: <bug-104848-4-eDKfmOvd85@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104848-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #4)
> The following example shows that bad overflow handling is a regression that
> was likely introduced in 6.x:
> 
> program p
>   integer, parameter :: b(0) = 1 + [ huge(1) ]
> end

Another potential fix for this is:

diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index fc9224ebc5c..67ef10d4bf7 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1710,8 +1720,8 @@ eval_intrinsic (gfc_intrinsic_op op,
   if (rc != ARITH_OK)
     {
       gfc_error (gfc_arith_error (rc), &op1->where);
-      if (rc == ARITH_OVERFLOW)
-       goto done;
+      // if (rc == ARITH_OVERFLOW)
+      //       goto done;

       if (rc == ARITH_DIV0 && op2->ts.type == BT_INTEGER)
        gfc_seen_div0 = true;

While this fixes the testcases in this PR, this regresses on the following:

gfortran.dg/pr84734.f90 (from r8-7226, which added the above commented code),

gfortran.dg/integer_exponentiation_6.F90 (from r5-7381)

The latter is a weird testcase, which changed behavior and prints different
values (0 for gfortran <= 8, 4611686018427387904 for gfortran >= 9).

(Other compilers print either 0 oder produce an error, so the current
behavior is sort of at odds with the others.)

Do we have a concept for how to handle integer and real overflow depending on
the flag -f(no-)range-check?

  parent reply	other threads:[~2022-10-19 19:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 20:00 [Bug fortran/104848] New: " gscfq@t-online.de
2022-03-09 19:34 ` [Bug fortran/104848] " anlauf at gcc dot gnu.org
2022-03-09 19:36 ` anlauf at gcc dot gnu.org
2022-03-09 19:54 ` anlauf at gcc dot gnu.org
2022-03-09 20:17 ` anlauf at gcc dot gnu.org
2022-10-19 19:18 ` anlauf at gcc dot gnu.org [this message]
2024-03-22 21:26 ` anlauf at gcc dot gnu.org
2024-03-22 21:30 ` anlauf at gcc dot gnu.org
2024-04-02 17:49 ` 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-104848-4-eDKfmOvd85@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).