This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR18575


The patch below fixes PR18375.

We were freeing the ss, then trying to free data pointed to from it.The 
obvious fix is to free the contained data before the ss itself.

Tested on i686-linux and powerpc-apple-darwin7.4.0.
Applied to mainline.

Paul

2004-11-10  Paul Brook  <paul@codesourcery.com>

 PR fortran/18375
 * trans-expr.c (gfc_trans_subarray_assign): Free shape before ss.
 * trans-io.c (transfer_array_component): Ditto.

Index: trans-expr.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/trans-expr.c,v
retrieving revision 1.31
diff -u -p -r1.31 trans-expr.c
--- trans-expr.c 8 Nov 2004 14:56:40 -0000 1.31
+++ trans-expr.c 10 Nov 2004 19:08:03 -0000
@@ -1566,12 +1566,12 @@ gfc_trans_subarray_assign (tree dest, gf
   gfc_add_block_to_block (&block, &loop.pre);
   gfc_add_block_to_block (&block, &loop.post);
 
-  gfc_cleanup_loop (&loop);
-
   for (n = 0; n < cm->as->rank; n++)
     mpz_clear (lss->shape[n]);
   gfc_free (lss->shape);
 
+  gfc_cleanup_loop (&loop);
+
   return gfc_finish_block (&block);
 }
 
Index: trans-io.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/fortran/trans-io.c,v
retrieving revision 1.23
diff -u -p -r1.23 trans-io.c
--- trans-io.c 8 Nov 2004 14:56:41 -0000 1.23
+++ trans-io.c 10 Nov 2004 19:08:47 -0000
@@ -1222,12 +1222,12 @@ transfer_array_component (tree expr, gfc
   gfc_add_block_to_block (&block, &loop.pre);
   gfc_add_block_to_block (&block, &loop.post);
 
-  gfc_cleanup_loop (&loop);
-
   for (n = 0; n < cm->as->rank; n++)
     mpz_clear (ss->shape[n]);
   gfc_free (ss->shape);
 
+  gfc_cleanup_loop (&loop);
+
   return gfc_finish_block (&block);
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]