[Patch, fortran] PR68566 ICE on using unusable array in reshape (double free or corruption)

Harald Anlauf anlauf@gmx.de
Thu Mar 17 22:11:00 GMT 2016


Hi,

the above ICE is fixed by the following simple/trivial fix:

Index: gcc/fortran/simplify.c
===================================================================
--- gcc/fortran/simplify.c      (revision 234170)
+++ gcc/fortran/simplify.c      (working copy)
@@ -5163,6 +5163,9 @@
       || !is_constant_array_expr (order_exp))
     return NULL;

+  if (source->shape == NULL)
+    return NULL;
+
   /* Proceed with simplification, unpacking the array.  */

   mpz_init (index);


Proposed testcase:

Index: gcc/testsuite/gfortran.dg/pr68566.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr68566.f90       (revision 0)
+++ gcc/testsuite/gfortran.dg/pr68566.f90       (revision 0)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/68566 - ICE on using unusable array in reshape
+! Testcase by Gerhard Steinmetz <gerhard.steinmetz.fortran at t-online.de>
+
+program p
+  integer, parameter :: a(:)   = 1      ! { dg-error "or of deferred
shape" }
+  integer, parameter :: b(2,2) = reshape([a], [2,2])
+end


Regtested with no new failures on i686-pc-linux-gnu.
Whoever wants to take it...

Cheers,
Harald



More information about the Gcc-patches mailing list