http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54784
janus at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org |gnu.org | --- Comment #5 from janus at gcc dot gnu.org 2012-10-02 23:43:42 UTC --- The following patch seems to cure the test case in comment 1, as well as both variants in comment 0: Index: gcc/fortran/trans-stmt.c =================================================================== --- gcc/fortran/trans-stmt.c (revision 192004) +++ gcc/fortran/trans-stmt.c (working copy) @@ -5145,7 +5145,9 @@ gfc_trans_allocate (gfc_code * code) dataref = actual->next->expr->ref; /* Make sure we go up through the reference chain to the _data reference, where the arrayspec is found. */ - while (dataref->next && dataref->next->type != REF_ARRAY) + while (!(dataref->type == REF_COMPONENT + && strcmp (dataref->u.c.component->name, "_data") == 0) + && dataref->next) dataref = dataref->next; if (dataref->u.c.component->as)