This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/70071] ICE on wrong usage of a subscript triplet


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

Harald Anlauf <anlauf at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gmx dot de

--- Comment #3 from Harald Anlauf <anlauf at gmx dot de> ---
(In reply to Gerhard Steinmetz from comment #0)
> $ cat z1.f90
> program p
>    integer, allocatable :: z(:)[:,:]
>    allocate (z(2)[1::2,*])
> end
> 
> $ gfortran-6 -fcoarray=single z1.f90
> f951: internal compiler error: gfc_ref_dimen_size(): Bad dimension

Potential fix (not regtested):

Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (revision 234170)
+++ gcc/fortran/array.c (working copy)
@@ -2173,9 +2184,15 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen,
   mpz_t diff;
   bool t;

-  if (dimen < 0 || ar == NULL || dimen > ar->dimen - 1)
+  if (dimen < 0 || ar == NULL)
     gfc_internal_error ("gfc_ref_dimen_size(): Bad dimension");

+  if (dimen > ar->dimen - 1)
+    {
+      gfc_error ("Bad array dimension at %L", &ar->c_where[dimen]);
+      return false;
+    }
+
   switch (ar->dimen_type[dimen])
     {
     case DIMEN_ELEMENT:


Which gives:

pr70071-z1.f90:3:18:

    allocate (z(2)[1::2,*])
                  1
Error: Bad array dimension at (1)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]