Hello world,
I committed the attached patch as obvious after regression-testing.
Revision is 177940.
Will commit to 4.6 in a few days.
Thomas
2011-08-21 Thomas Koenig <[email protected]>
PR fortran/50130
* resolve.c (resolve_array_ref): Don't calculate upper bound
if the stride is zero.
2011-08-21 Thomas Koenig <[email protected]>
PR fortran/50130
* gfortran.dg/zero_stride_1.f90: New test
Index: resolve.c
===================================================================
--- resolve.c (Revision 177746)
+++ resolve.c (Arbeitskopie)
@@ -4569,10 +4569,11 @@ resolve_array_ref (gfc_array_ref *ar)
/* Fill in the upper bound, which may be lower than the
specified one for something like a(2:10:5), which is
identical to a(2:7:5). Only relevant for strides not equal
- to one. */
+ to one. Don't try a division by zero. */
if (ar->dimen_type[i] == DIMEN_RANGE
&& ar->stride[i] != NULL && ar->stride[i]->expr_type == EXPR_CONSTANT
- && mpz_cmp_si (ar->stride[i]->value.integer, 1L) != 0)
+ && mpz_cmp_si (ar->stride[i]->value.integer, 1L) != 0
+ && mpz_cmp_si (ar->stride[i]->value.integer, 0L) != 0)
{
mpz_t size, end;
! { dg-do compile }
! PR 50130 - this caused an ICE. Test case supplied by Joost
! VandeVondele.
integer, parameter :: a(10)=0
integer, parameter :: b(10)=a(1:10:0) ! { dg-error "Illegal stride of zero" }
END