https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88364
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- A simple fix is not to do the clobbers if there is a reference: Index: trans-expr.c =================================================================== --- trans-expr.c (Revision 266250) +++ trans-expr.c (Arbeitskopie) @@ -8152,7 +8152,7 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * e gfc_add_block_to_block (&se->pre, &se->post); se->expr = var; } - else if (add_clobber) + else if (add_clobber && expr->ref == NULL) { tree clobber; tree var; A bit more sophisticated would be to actually build the correct clobber in this case. I'm inclined to commit the patch above and open a new PR for the missed optimization, but I won't have time for either in the next few days. So, if anybody wants to do anything about this, be my guest :-)