This is the mail archive of the gcc-bugs@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]

[Bug fortran/61831] [4.9/ 5 Regression] runtime error: pointer being freed was not allocated


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61831

--- Comment #42 from Mikael Morin <mikael at gcc dot gnu.org> ---
(In reply to Mikael Morin from comment #41)
> My work patch is:

updated work patch below.
The testcase passes with it, at the price of leaking memory

Index: trans-expr.c
===================================================================
--- trans-expr.c    (rÃvision 220717)
+++ trans-expr.c    (copie de travail)
@@ -4949,7 +4949,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol *
       if (e && (e->ts.type == BT_DERIVED || e->ts.type == BT_CLASS)
         && e->ts.u.derived->attr.alloc_comp
         && !(e->symtree && e->symtree->n.sym->attr.pointer)
-        && (e->expr_type != EXPR_VARIABLE && !e->rank))
+        && (e->expr_type != EXPR_VARIABLE
+        && e->expr_type != EXPR_STRUCTURE && !e->rank))
         {
       int parm_rank;
       tmp = build_fold_indirect_ref_loc (input_location,
@@ -7131,7 +7132,8 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * e
   if (expr->ts.type == BT_DERIVED && expr->rank
       && !gfc_is_finalizable (expr->ts.u.derived, NULL)
       && expr->ts.u.derived->attr.alloc_comp
-      && expr->expr_type != EXPR_VARIABLE)
+      && expr->expr_type != EXPR_VARIABLE
+      && expr->expr_type != EXPR_ARRAY)
     {
       tree tmp;

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