From 459e77b859a96bc4dd3cfd53895c8dccfa0de679 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 29 Dec 2017 14:27:59 +0000 Subject: [PATCH] re PR fortran/83567 (Parametrized derived types: Segmentation fault when assigning a function return value) 2017-12-28 Paul Thomas PR fortran/83567 * trans-expr.c (gfc_trans_assignment_1): Free parameterized components of the lhs if dealloc is set. *trans-decl.c (gfc_trans_deferred_vars): Do not free the parameterized components of function results on leaving scope. 2017-12-28 Paul Thomas PR fortran/83567 * gfortran.dg/pdt_26.f90 : New test. From-SVN: r256033 --- gcc/fortran/trans-expr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 30151dd9fa4..756fd6ab85a 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -10078,7 +10078,8 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag, } /* Deallocate the lhs parameterized components if required. */ - if (dealloc && expr2->expr_type == EXPR_FUNCTION) + if (dealloc && expr2->expr_type == EXPR_FUNCTION + && !expr1->symtree->n.sym->attr.associate_var) { if (expr1->ts.type == BT_DERIVED && expr1->ts.u.derived -- 2.30.2