Hello world, I have committed the attached patch as obvious and simple after regression-testing.
It fixes an ICE on valid for a corner case, so I don't really feel that it needs to be backported. If anybody disagrees, please speak up (or do it yourself :-) Regards Thomas 2019-10-13 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/92017 * expr.c (simplify_parameter_variable): Set the character length of the result expression from the original expression if necessary. 2019-10-13 Thomas Koenig <tkoe...@gcc.gnu.org> PR fortran/92017 * gfortran.dg/minmaxloc_14.f90: New test.
Index: expr.c =================================================================== --- expr.c (Revision 276937) +++ expr.c (Arbeitskopie) @@ -2066,6 +2066,9 @@ simplify_parameter_variable (gfc_expr *p, int type e->rank = p->rank; + if (e->ts.type == BT_CHARACTER && e->ts.u.cl == NULL) + e->ts.u.cl = gfc_new_charlen (gfc_current_ns, p->ts.u.cl); + /* Do not copy subobject refs for constant. */ if (e->expr_type != EXPR_CONSTANT && p->ref != NULL) e->ref = gfc_copy_ref (p->ref);
! { dg-do compile } ! PR 92017 - this used to cause an ICE due do a missing charlen. ! Original test case by Gerhard Steinmetz. program p character(3), parameter :: a(4) = 'abc' integer, parameter :: b(1) = minloc(a) integer, parameter :: c = minloc(a, dim=1) integer, parameter :: bb(1) = maxloc(a) integer, parameter :: c2 = maxloc(a,dim=1) end program p