[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression arrayio_16
Mikael Morin
mikael@gcc.gnu.org
Fri Jun 13 14:58:26 GMT 2025
https://gcc.gnu.org/g:23de2e883600d01fbfbbe82407c470be55cfe0f5
commit 23de2e883600d01fbfbbe82407c470be55cfe0f5
Author: Mikael Morin <mikael@gcc.gnu.org>
Date: Thu Apr 24 13:30:07 2025 +0200
Correction régression arrayio_16
Diff:
---
gcc/fortran/libgfortran.h | 1 +
libgfortran/io/list_read.c | 12 ++++++++++++
libgfortran/io/unix.c | 2 +-
libgfortran/runtime/error.c | 4 ++++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index 9de5afb6c83e..b592c1477879 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -143,6 +143,7 @@ typedef enum
LIBERROR_INQUIRE_INTERNAL_UNIT, /* Must be different from STAT_STOPPED_IMAGE. */
LIBERROR_BAD_WAIT_ID,
LIBERROR_NO_MEMORY,
+ LIBERROR_MISALIGNED_INTERNAL_UNIT,
LIBERROR_LAST /* Not a real error, the last error # + 1. */
}
libgfortran_error_codes;
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index 21a935bc4c4d..a8658c61b5df 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -251,6 +251,18 @@ next_char_internal (st_parameter_dt *dtp)
goto done;
}
+ if (unlikely (is_char4_unit(dtp)))
+ {
+ if (unlikely (record % sizeof (gfc_char4_t) != 0))
+ {
+ generate_error (&dtp->common,
+ LIBERROR_MISALIGNED_INTERNAL_UNIT, NULL);
+ return '\0';
+ }
+ else
+ record /= sizeof (gfc_char4_t);
+ }
+
if (sseek (dtp->u.p.current_unit->s, record, SEEK_SET) < 0)
return EOF;
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 129e2dbf0916..68afb0ad627c 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1098,7 +1098,7 @@ open_internal4 (char *base, size_t length, gfc_offset offset)
s->buffer = base;
s->buffer_offset = offset;
- s->active = s->file_length = length * sizeof (gfc_char4_t);
+ s->active = s->file_length = length;
s->st.vptr = &mem4_vtable;
diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index d2ae7be16f41..444bb38bcdb5 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -633,6 +633,10 @@ translate_error (int code)
p = "Bad ID in WAIT statement";
break;
+ case LIBERROR_MISALIGNED_INTERNAL_UNIT:
+ p = "Misaligned offset reading internal file";
+ break;
+
default:
p = "Unknown error code";
break;
More information about the Gcc-cvs
mailing list