https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99348
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #3 from anlauf at gcc dot gnu.org ---
There's no ICE when x is scalar:
type(t), parameter :: x = t('abc')
With the following patch we avoid the NULL pointer dereference at
resolve.c:1286
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 1c9b0c5cb62..0b9e11cdd41 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1282,7 +1282,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
/* A constructor may have references if it is the result of substituting a
parameter variable. In this case we just pull out the component we
want. */
- if (expr->ref)
+ if (expr->ref && expr->ref->u.c.sym)
comp = expr->ref->u.c.sym->components;
else
comp = expr->ts.u.derived->components;
but later run into an issue at expr.c:1917:
1913 for (c = gfc_constructor_first
(p->value.constructor);
1914 c; c = gfc_constructor_next (c))
1915 {
1916 c->expr->ref = gfc_copy_ref (p->ref->next);
1917 if (!simplify_const_ref (c->expr))
1918 return false;
1919 }
(gdb) p c->expr->ts.u.cl->length
$104 = (gfc_expr *) 0x0
(gdb) p c->expr->value.character.length
$105 = 3
This leads to an ICE during processing simplify_const_ref.