Hello world, the attached patch fixes a bug, partly an 8 regression, for simplifying an expression containing minloc or maxloc. The underlying problem was that integer, dimension(0), parameter :: z=0 ended up as EXPR_CONSTANT even though the rank was one, which was then passed to the simplification routines, which either ICEd or gave wrong results. In doing this, I had to change the logic of the is_size_zero_array function. Trying to call it from within the simplification rountines led to the simplification routines to be called, and so on... until the stack ran out. As soon as this is committed, I'll also look if there is anything left in PR66128, and close that bug if appropriate Regression-tested. OK for trunk? 2017-03-06 Thomas Koenig PR fortran/84697 PR fortran/66128 * expr.c (simplify_parameter_variable): If p is a size zero array and not an ARRAY_EXPR insert an empty array constructor and return. * gfortran.h: Add prototype for gfc_is_size_zero_array. * simplify.c (is_size_zero_array): Make non-static and rename into (gfc_is_size_zero_array): Check for parameter arrays of zero size by comparing shape and absence of constructor. (gfc_simplify_all): Use gfc_is_size_zero_array instead of is_size_zero_array. (gfc_simplify_count): Likewise. (gfc_simplify_iall): Likewise. (gfc_simplify_iany): Likewise. (gfc_simplify_iparity): Likewise. (gfc_simplify_minval): Likewise. (gfc_simplify_maxval): Likewise. (gfc_simplify_product): Likewise. (gfc_simplify_sum): Likewise. 2017-03-06 Thomas Koenig PR fortran/84697 PR fortran/66128 * gfortran.dg/minmaxloc_zerosize_1.f90: New test.