https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109948
--- Comment #16 from anlauf at gcc dot gnu.org --- (In reply to Paul Thomas from comment #15) > Created attachment 55225 [details] > Fix for this PR > > The attached patch substantially tidies up parse_associate and fixes: LGTM! I was close to proposing a hack for gfc_expression_rank that checks whether the variable's select_type_temporary, select_rank_temporary and associate_var attributes to decide which ref to evaluate. But your patch seems to be a much better approach. BTW: after your patch, the attribute assoc->rankguessed is no longer set. It is tested in two locations in resolve_assoc_var(resolve.cc), where it might be removed after your fix.