------- Comment #18 from fxcoudert at gcc dot gnu dot org  2008-05-28 17:26 
-------
For the memory leak that happens from simplify_parameter_variable(), a reduced
testcase is:

  integer, parameter :: MSKa1(1) = 1
  integer, parameter :: ARR1 = MSKa1(1)
  end

The reason for it is that when we change the expression rank in
simplify_parameter_variable(), we don't change the shape accordingly. I think
it should be done like that:

Index: expr.c
===================================================================
--- expr.c      (revision 135515)
+++ expr.c      (working copy)
@@ -1522,12 +1522,20 @@ simplify_parameter_variable (gfc_expr *p
 {
   gfc_expr *e;
   try t;
+  int n;

   e = gfc_copy_expr (p->symtree->n.sym->value);
   if (e == NULL)
     return FAILURE;

+  /* Copy the rank and shape from p, but first clear the existing shape.  */
+  if (e->shape)
+    for (n = 0; n < e->rank; n++)
+      mpz_clear (e->shape[n]);
+
+  gfc_free (e->shape);
   e->rank = p->rank;
+  e->shape = gfc_copy_shape (p->shape, p->rank);

   /* Do not copy subobject refs for constant.  */
   if (e->expr_type != EXPR_CONSTANT && p->ref != NULL)


That patch seems to regtest fine, but I don't see how it could fix the original
ICE.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34828

Reply via email to