[Bug fortran/68567] ICE on using wrong defined arrays (different cases/messages)

kargl at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Aug 22 19:00:00 GMT 2016


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

kargl at gcc dot gnu.org changed:

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

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to Gerhard Steinmetz from comment #3)
> ICE is gone for all tested constellations with
> gcc-Version 7.0.0 20160821 (experimental) (GCC)

We must be using drastically different compilers.  With your

% cat a.f90
program p
   integer, parameter :: a(:) = [2, 1]
   integer :: b = a(a(1))
end

I get an ICE.

% gfc6 -o z a.f90
f951: internal compiler error: Segmentation fault
0xa53fff crash_signal
        ../../gcc6/gcc/toplev.c:333
0x5da9e3 gfc_reduce_init_expr(gfc_expr*)
        ../../gcc6/gcc/fortran/expr.c:2676
0x5dae33 find_array_element
        ../../gcc6/gcc/fortran/expr.c:1206

With the obvious simple patch,

% svn diff gcc/fortran/expr.c 
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c  (revision 239661)
+++ gcc/fortran/expr.c  (working copy)
@@ -2670,7 +2670,7 @@ gfc_reduce_init_expr (gfc_expr *expr)
     t = gfc_check_init_expr (expr);
   gfc_init_expr_flag = false;

-  if (!t)
+  if (!t || !expr)
     return false;

   if (expr->expr_type == EXPR_ARRAY)

I get

% gfc7 -o z a.f90
a.f90:3:3:

    integer :: b = a(a(1))
   1
Error: Unclassifiable statement at (1)
a.f90:2:29:

    integer, parameter :: a(:) = [2, 1]
                             1
Error: Parameter array 'a' at (1) cannot be automatic or of deferred shape


More information about the Gcc-bugs mailing list