https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98307
--- Comment #2 from anlauf at gcc dot gnu.org ---
I'm regtesting the following patch candidate:
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index adc6b8fefb5..e35b2f9ed34 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -3951,7 +3951,8 @@ check_forall_dependencies (gfc_code *c, stmtblock_t *pre,
stmtblock_t *post)
pointer components. We therefore leave these to their
own devices. */
if (lsym->ts.type == BT_DERIVED
- && lsym->ts.u.derived->attr.pointer_comp)
+ && (lsym->ts.u.derived->attr.pointer_comp
+ || lsym->ts.u.derived->attr.alloc_comp))
return need_temp;
new_symtree = NULL;