This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] Fix module I/O with assumed-rank arrays
- From: Tobias Burnus <burnus at net-b dot de>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Jul 2012 22:08:01 +0200
- Subject: [Patch, Fortran] Fix module I/O with assumed-rank arrays
The following issue was found by Alessandro. (It got triggered by a
larger test case, which is required for a larger patch by Alessandro,
which is not yet finished.)
Accessing the "lower[-1]" is probably not the best idea â
Build on x86-64-linux.
OK for the trunk?
Tobias
2012-07-25 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Tobias Burnus <burnus@net-b.de>
* module.c (mio_array_spec): Don't read as->lower for
assumed-rank arrays.
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index a3b9088..51b7059 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -2381,11 +2381,12 @@ mio_array_spec (gfc_array_spec **asp)
if (iomode == IO_INPUT && as->corank)
as->cotype = (as->type == AS_DEFERRED) ? AS_DEFERRED : AS_EXPLICIT;
- for (i = 0; i < as->rank + as->corank; i++)
- {
- mio_expr (&as->lower[i]);
- mio_expr (&as->upper[i]);
- }
+ if (as->rank > 0)
+ for (i = 0; i < as->rank + as->corank; i++)
+ {
+ mio_expr (&as->lower[i]);
+ mio_expr (&as->upper[i]);
+ }
done:
mio_rparen ();