https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58331
--- Comment #5 from anlauf at gcc dot gnu.org --- The previous patch would accept invalid code, as it would miss assumed-shape. Fixed by the additional: @@ -2650,10 +2669,14 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual, if (symbol_rank (formal) == actual->rank || symbol_rank (formal) == -1) return true; - rank_check = where != NULL && !is_elemental && formal->as - && (formal->as->type == AS_ASSUMED_SHAPE - || formal->as->type == AS_DEFERRED) - && actual->expr_type != EXPR_NULL; + gfc_array_spec *formal_as; + formal_as = formal->ts.type == BT_CLASS ? CLASS_DATA (formal)->as + : formal->as; + + rank_check = where != NULL && !is_elemental && formal_as + && (formal_as->type == AS_ASSUMED_SHAPE + || formal_as->type == AS_DEFERRED) + && actual->expr_type != EXPR_NULL; /* Skip rank checks for NO_ARG_CHECK. */ if (formal->attr.ext_attr & (1 << EXT_ATTR_NO_ARG_CHECK))