Hello world, Steve had analyzed the bug and provided a patch in the PR; I modified the patch stylistically and committed it as obvious after regression-testing (r253123).
Thanks Steve! Since this is a regression, I will backport soon. Regards Thomas 2017-09-24 Thomas Koenig <tkoe...@gcc.gnu.org> Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/80118 * expr.c (gfc_get_full_arrayspec_from_expr): If there is no symtree, set array spec to NULL. 2017-09-24 Thomas Koenig <tkoe...@gcc.gnu.org> Steven G. Kargl <ka...@gcc.gnu.org> PR fortran/80118 * gfortran.dg/zero_sized_7.f90: New test.
! { dg-do compile } ! PR 80118 - this used to ICE ! Original test case by Marco Restelli module m implicit none integer, parameter :: not_empty(1) = 0 integer, parameter :: empty1(0) = (/integer :: /) integer, parameter :: empty2(0) = 0 contains subroutine sub(v) integer, allocatable, intent(out) :: v(:) v = 2*empty2 ! internal compiler error end subroutine sub end module m
Index: expr.c =================================================================== --- expr.c (Revision 253116) +++ expr.c (Arbeitskopie) @@ -4568,7 +4568,11 @@ gfc_get_full_arrayspec_from_expr (gfc_expr *expr) if (expr->expr_type == EXPR_VARIABLE || expr->expr_type == EXPR_CONSTANT) { - as = expr->symtree->n.sym->as; + if (expr->symtree) + as = expr->symtree->n.sym->as; + else + as = NULL; + for (ref = expr->ref; ref; ref = ref->next) { switch (ref->type)