This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/34828] ICE: GNU MP: Cannot reallocate memory for gfortran.dg/parameter_array_init_3.f90
- From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 May 2008 17:26:27 -0000
- Subject: [Bug fortran/34828] ICE: GNU MP: Cannot reallocate memory for gfortran.dg/parameter_array_init_3.f90
- References: <bug-34828-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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