http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56765
--- Comment #3 from janus at gcc dot gnu.org 2013-03-29 21:30:03 UTC --- With this patch ... Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 196862) +++ gcc/fortran/resolve.c (working copy) @@ -2538,7 +2538,9 @@ found: expr->ts = sym->ts; expr->value.function.name = sym->name; expr->value.function.esym = sym; - if (sym->as != NULL) + if (sym->result->ts.type == BT_CLASS && CLASS_DATA (sym->result)->as) + expr->rank = CLASS_DATA (sym->result)->as->rank; + else if (sym->as != NULL) expr->rank = sym->as->rank; return MATCH_YES; ... the behavior of the two test cases is swapped: The second one is (correctly) rejected, while the first one ends up with the ICE.