The attach patch guards against a NULL pointer deference and removes asserts that cannot trigger.
2018-12-08 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/88025 * expr.c (gfc_apply_init): Remove asserts that cannot trigger. Check for a NULL pointer. 2018-12-08 Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/88025 * gfortran.dg/pr88025.f90: New test. -- Steve
Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 266912) +++ gcc/fortran/expr.c (working copy) @@ -4485,12 +4485,10 @@ gfc_apply_init (gfc_typespec *ts, symbol_attribute *at { if (ts->type == BT_CHARACTER && !attr->pointer && init && ts->u.cl - && ts->u.cl->length && ts->u.cl->length->expr_type == EXPR_CONSTANT) + && ts->u.cl->length + && ts->u.cl->length->expr_type == EXPR_CONSTANT + && ts->u.cl->length->ts.type == BT_INTEGER) { - gcc_assert (ts->u.cl && ts->u.cl->length); - gcc_assert (ts->u.cl->length->expr_type == EXPR_CONSTANT); - gcc_assert (ts->u.cl->length->ts.type == BT_INTEGER); - HOST_WIDE_INT len = gfc_mpz_get_hwi (ts->u.cl->length->value.integer); if (init->expr_type == EXPR_CONSTANT) Index: gcc/testsuite/gfortran.dg/pr88025.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr88025.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr88025.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +! PR fortran/88025 +program p + type t + character(('')) :: c = 'c' ! { dg-error "must be of INTEGER type" } + end type +end