This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/61831] [4.9/ 4.10 Regression] runtime error: pointer being freed was not allocated
- From: "dominiq at lps dot ens.fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 Jul 2014 19:30:01 +0000
- Subject: [Bug fortran/61831] [4.9/ 4.10 Regression] runtime error: pointer being freed was not allocated
- Auto-submitted: auto-generated
- References: <bug-61831-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61831
--- Comment #23 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Could you test the following patch?
--- ../_clean/gcc/fortran/trans-expr.c 2014-07-07 22:48:04.000000000 +0200
+++ gcc/fortran/trans-expr.c 2014-07-18 21:28:24.000000000 +0200
@@ -6512,7 +6512,10 @@ gfc_conv_expr_reference (gfc_se * se, gf
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
+ || (expr->expr_type == EXPR_ARRAY
+ && expr->ts.u.derived->refs == 1)))
{
tree tmp;