https://gcc.gnu.org/g:d5b72c30bbedb55266aab3dc0a2875c4e6ab27cf

commit d5b72c30bbedb55266aab3dc0a2875c4e6ab27cf
Author: Mikael Morin <[email protected]>
Date:   Thu Oct 2 16:19:43 2025 +0200

    Correction régression arrayio_16.f90

Diff:
---
 gcc/fortran/trans-io.cc    |  1 +
 libgfortran/io/list_read.c | 10 ++++++----
 libgfortran/io/transfer.c  |  2 +-
 libgfortran/io/unix.c      | 21 +--------------------
 4 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index a16e404b90bc..38865a587b30 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -956,6 +956,7 @@ set_internal_unit (stmtblock_t * block, stmtblock_t * 
post_block,
       else
        {
          /* Return the data pointer and rank from the descriptor.  */
+         se.bytes_strided = 1;
          gfc_conv_expr_descriptor (&se, e);
          tmp = gfc_conv_descriptor_data_get (se.expr);
          se.expr = gfc_build_addr_expr (pchar_type_node, se.expr);
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 12beaf93349f..9d861eb93b8e 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -263,7 +263,7 @@ next_char_internal (st_parameter_dt *dtp)
   if (likely (dtp->u.p.current_unit->bytes_left > 0))
     {
       if (unlikely (is_char4_unit(dtp))) /* Check for kind=4 internal unit.  */
-       length = sread (dtp->u.p.current_unit->s, &c, 1);
+       length = sread (dtp->u.p.current_unit->s, &c, sizeof (gfc_char4_t));
       else
        {
         char cc;
@@ -386,16 +386,17 @@ eat_spaces (st_parameter_dt *dtp)
   if (is_array_io (dtp) && (dtp->u.p.current_unit->last_char == EOF - 1))
     {
       gfc_offset offset = stell (dtp->u.p.current_unit->s);
-      gfc_offset i;
+      gfc_offset i, final_position;
 
       if (is_char4_unit(dtp)) /* kind=4 */
        {
          for (i = 0; i < dtp->u.p.current_unit->bytes_left; i++)
            {
-             if (dtp->internal_unit[(offset + i) * sizeof (gfc_char4_t)]
+             if (dtp->internal_unit[offset + i * sizeof (gfc_char4_t)]
                  != (gfc_char4_t)' ')
                break;
            }
+         final_position = offset + i * sizeof (gfc_char4_t);
        }
       else
        {
@@ -404,11 +405,12 @@ eat_spaces (st_parameter_dt *dtp)
              if (dtp->internal_unit[offset + i] != ' ')
                break;
            }
+         final_position = offset + i;
        }
 
       if (i != 0)
        {
-         sseek (dtp->u.p.current_unit->s, offset + i, SEEK_SET);
+         sseek (dtp->u.p.current_unit->s, final_position, SEEK_SET);
          dtp->u.p.current_unit->bytes_left -= i;
        }
     }
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 4b28d03edbde..a223c09dda88 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -320,7 +320,7 @@ read_sf_internal (st_parameter_dt *dtp, size_t *length)
       if (is_char4_unit(dtp))
        {
          gfc_char4_t *p = (gfc_char4_t *) mem_alloc_r4 
(dtp->u.p.current_unit->s,
-                           length);
+                                                        length);
          base = fbuf_alloc (dtp->u.p.current_unit, lorig);
          for (size_t i = 0; i < *length; i++, p++)
            base[i] = *p > 255 ? '?' : (unsigned char) *p;
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 68afb0ad627c..97f6b83d3455 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -908,25 +908,6 @@ mem_read (stream *s, void *buf, ssize_t nbytes)
 }
 
 
-/* Stream read function for chracter(kind=4) internal units.  */
-
-static ssize_t
-mem_read4 (stream *s, void *buf, ssize_t nbytes)
-{
-  void *p;
-  size_t nb = nbytes;
-
-  p = mem_alloc_r4 (s, &nb);
-  if (p)
-    {
-      memcpy (buf, p, nb * 4);
-      return (ssize_t) nb;
-    }
-  else
-    return 0;
-}
-
-
 /* Stream write function for character(kind=1) internal units.  */
 
 static ssize_t
@@ -1047,7 +1028,7 @@ static const struct stream_vtable mem_vtable = {
 };
 
 static const struct stream_vtable mem4_vtable = {
-  .read = (void *) mem_read4,
+  .read = (void *) mem_read,
   .write = (void *) mem_write4,
   .seek = (void *) mem_seek,
   .tell = (void *) mem_tell,

Reply via email to