https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70244
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |ice-on-valid-code Status|UNCONFIRMED |NEW Last reconfirmed| |2016-03-16 CC| |burnus at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> --- Confirmed with GCC 6. The ICE is triggered for: 0x61723e spec_dimen_size(gfc_array_spec*, int, __mpz_struct (*) [1]) 2118 if (dimen < 0 || dimen > as->rank - 1) as dimen == 1 and as->rank == 1. That's called via "gfc_array_dimen_size", which first has: case EXPR_FUNCTION: for (ref = array->ref; ref; ref = ref->next) but that never gets executed as one has one REF_ARRAY of type AR_ELEMENT and then 4 REF_COMPONENT. Thus, the following code is used: else if (!spec_dimen_size (array->symtree->n.sym->as, dimen, result)) which resolves to "e" which is a rank-1 array. That fails as the proper "as" is the one at array->ref->next->next->next->u.c.component->as Replacing the check in "gfc_array_dimen_size" by the following should works: gfc_array_spec *as = gfc_get_full_arrayspec_from_expr (array); if (!spec_dimen_size (as, dimen, result)) return false; One just has to check which parts in gfc_array_dimen_size can be replaced by this and whether all special cases are taken care of in gfc_get_full_arrayspec_from_expr.