[Bug fortran/107968] array slicing gives wrong result for an array pointer defined in a subroutine
anlauf at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 2 18:45:30 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107968
--- Comment #4 from anlauf at gcc dot gnu.org ---
This also fixes the issue:
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index df2fef70172..d644e0c9206 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -2646,6 +2646,7 @@ gfc_trans_transfer (gfc_code * code)
&& ((expr->symtree->n.sym->ts.type == BT_DERIVED && expr->ts.deferred)
|| (expr->symtree->n.sym->assoc
&& expr->symtree->n.sym->assoc->variable)
+ || gfc_expr_attr (expr).target
|| gfc_expr_attr (expr).pointer))
goto scalarize;
I have to think a little longer whether we have to do this, but this
seems safe.
More information about the Gcc-bugs
mailing list