While trying to clean up my working copy, I found that the trivial patch for the ICE-on-invalid as described in the PR regtests cleanly for 7-release on i686-pc-linux-gnu.
Here's the cleaned-up version (diffs attached). 2017-05-04 Harald Anlauf <anl...@gmx.de> PR fortran/70071 * array.c (gfc_ref_dimen_size): Handle bad subscript triplets. 2017-05-04 Harald Anlauf <anl...@gmx.de> PR fortran/70071 * gfortran.dg/coarray_44.f90: New testcase. If somebody wants to forward port this to 8-trunk, please go ahead. Thanks, Harald
Index: gcc/fortran/array.c =================================================================== --- gcc/fortran/array.c (revision 247015) +++ gcc/fortran/array.c (working copy) @@ -2202,9 +2202,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:
Index: gcc/testsuite/gfortran.dg/coarray_44.f90 =================================================================== --- gcc/testsuite/gfortran.dg/coarray_44.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/coarray_44.f90 (revision 0) @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-fcoarray=single" } +! +! PR fortran/70071 +! Based on testcases by Gerhard Steinmetz + +program pr70071 + implicit none + integer, allocatable :: z(:)[:,:] + allocate (z(2)[1::2,*]) ! { dg-error "Bad array dimension" } + allocate (z(1::2)[2,*]) ! { dg-error "Bad array specification in ALLOCATE" } +end program pr70071