[Bug fortran/105230] [9/10/11/12/13 Regression] ICE in find_array_section, at fortran/expr.cc:1634

anlauf at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 10 19:02:45 GMT 2022


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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #1)
> Started with 22015e77d3e4.

No, it didn't start with that commit.  That commit missed the present
situation.
The ICE is pre-existing.

> upper is NULL and later in 1634 it is dereferenced.  This patch fixes
> the problem, but the above logic likely needs fixing.

That's right.  Shorter fix:

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 86d61fed302..be94c18c836 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1595,8 +1595,8 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
          if ((begin && begin->expr_type != EXPR_CONSTANT)
              || (finish && finish->expr_type != EXPR_CONSTANT)
              || (step && step->expr_type != EXPR_CONSTANT)
-             || (!begin && !lower)
-             || (!finish && !upper))
+             || !lower
+             || !upper)
            {
              t = false;
              goto cleanup;


More information about the Gcc-bugs mailing list