This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/49324] Deep copy missing for array constructors of DT w/ allocatable components
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 9 Jun 2011 22:23:10 +0000
- Subject: [Bug fortran/49324] Deep copy missing for array constructors of DT w/ allocatable components
- Auto-submitted: auto-generated
- References: <bug-49324-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49324
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-06-09 22:22:39 UTC ---
The following should partially helps: It solves the segfault for
z(:) = [ x, y ]
and does a deep copy.
TODO:
- I miss a freeing of the components of the LHS, there is currently just a
malloc, cf.
- Realloc on assign does not work properly:
* Valgrind shows: "Conditional jump or move depends on uninitialised value"
* Values print Ok, but afterwards it segfaults
- with reshape, the values are still wrong.
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5347,6 +5347,9 @@ gfc_trans_scalar_assign (gfc_se * lse, gfc_se * rse,
gfc_typespec ts,
tmp);
gfc_add_expr_to_block (&block, tmp);
}
+ else
+ gfc_add_expr_to_block (&block,gfc_copy_alloc_comp (ts.u.derived,
+ rse->expr,
lse->expr, 0));
}
else if (ts.type == BT_DERIVED || ts.type == BT_CLASS)
{