http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48700
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #3 from janus at gcc dot gnu.org 2011-05-15 12:18:57 UTC ---
(In reply to comment #2)
> We miss to deallocate "sm", before it gets overridden.
Simple patch which does just that (not regtested):
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (revision 173579)
+++ gcc/fortran/trans-intrinsic.c (working copy)
@@ -6961,12 +6961,20 @@ gfc_conv_intrinsic_move_alloc (gfc_code *code)
gfc_expr *from, *to;
stmtblock_t block;
tree tmp;
+ gfc_se se;
from = code->ext.actual->expr;
to = code->ext.actual->next->expr;
gfc_start_block (&block);
+ /* Deallocate 'TO' argument. */
+ gfc_init_se (&se, NULL);
+ se.want_pointer = 1;
+ gfc_conv_expr (&se, to);
+ tmp = gfc_deallocate_scalar_with_status (se.expr, NULL, true, to,
to->ts);
+ gfc_add_expr_to_block (&block, tmp);
+
if (to->ts.type == BT_CLASS)
tmp = gfc_trans_class_assign (to, from, EXEC_POINTER_ASSIGN);
else