https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107968

--- Comment #2 from anlauf at gcc dot gnu.org ---
The following attempt fixes the erroneous output:

diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index 9f86815388c..c4525f67ef3 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -2641,6 +2641,9 @@ gfc_trans_transfer (gfc_code * code)
                    seen_vector = true;
                    break;
                  }
+
+             if (!seen_vector && !gfc_is_not_contiguous (expr))
+               goto scalarize;
            }

          if (seen_vector && last_dt == READ)

However, this defeats the optimization on array I/O and regresses on

gfortran.dg/implied_do_io_1.f90
gfortran.dg/implied_do_io_4.f90

Reply via email to