diff mbox

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

Message ID 56EB230F.8060900@gmx.de
State New
Headers show

Commit Message

Harald Anlauf March 17, 2016, 9:35 p.m. UTC
Hi,

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

+end


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

Cheers,
Harald
diff mbox

Patch

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])