This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32795] allocatable components are nullified prematurely
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2008 22:14:47 -0000
- Subject: [Bug fortran/32795] allocatable components are nullified prematurely
- References: <bug-32795-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from burnus at gcc dot gnu dot org 2008-01-30 22:14 -------
Paul's patch with and added if condition (see below) nicely compiles all
examples + regtests; however, the example of comment 2 gives a wrong result
("< >" instead of "< 1 2 3 >") [this is independent of the patch]. For that
test case 12 bytes are lost according to valgrind. Actually, if one specifies
the explicit bonds, i.e. "x%i(1:)" or "x%i(:3)" instead of "x%i(:)" or "x%i",
a temporary variable is created and "< 1 2 3 >" is correctly printed.
/* Use the scalar assignment as is. */
+ if (expr->ts.type == BT_DERIVED)
+ {
+ falselhs = gfc_evaluate_now (lse.expr, &lse.pre);
+ falselhs = gfc_deallocate_alloc_comp (expr->ts.derived, falselhs, 0);
+ gfc_add_expr_to_block (&lse.post, falselhs);
+ }
gfc_add_block_to_block (&block, &lse.pre);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32795