https://gcc.gnu.org/g:2b847cde690bfe27d5dfc5a601117b76fbf19f34

commit 2b847cde690bfe27d5dfc5a601117b76fbf19f34
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Wed Apr 30 22:56:30 2025 +0200

    Correction régression maxval_char_2

Diff:
---
 libgfortran/io/transfer.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 805bdcd8067b..043ca3606b2a 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -3934,6 +3934,18 @@ next_record_r (st_parameter_dt *dtp, int done)
              if (!done && finished)
                hit_eof (dtp);
 
+             if (unlikely (is_char4_unit(dtp)))
+               {
+                 if (unlikely (record % sizeof (gfc_char4_t) != 0))
+                   {
+                     generate_error (&dtp->common,
+                                     LIBERROR_MISALIGNED_INTERNAL_UNIT, NULL);
+                     break;
+                   }
+                 else
+                   record /= sizeof (gfc_char4_t);
+               }
+
              /* Now seek to this record.  */
              if (sseek (dtp->u.p.current_unit->s, record, SEEK_SET) < 0)
                {
@@ -4270,6 +4282,18 @@ next_record_w (st_parameter_dt *dtp, int done)
              if (finished)
                dtp->u.p.current_unit->endfile = AT_ENDFILE;
 
+             if (unlikely (is_char4_unit(dtp)))
+               {
+                 if (unlikely (record % sizeof (gfc_char4_t) != 0))
+                   {
+                     generate_error (&dtp->common,
+                                     LIBERROR_MISALIGNED_INTERNAL_UNIT, NULL);
+                     break;
+                   }
+                 else
+                   record /= sizeof (gfc_char4_t);
+               }
+           
              /* Now seek to this record */
              if (sseek (dtp->u.p.current_unit->s, record, SEEK_SET) < 0)
                {

Reply via email to