From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5699 invoked by alias); 28 Jul 2007 20:52:20 -0000 Received: (qmail 5671 invoked by uid 48); 28 Jul 2007 20:52:12 -0000 Date: Sat, 28 Jul 2007 20:52:00 -0000 Message-ID: <20070728205212.5670.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/32795] allocatable components are nullified prematurely In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pault at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg02898.txt.bz2 ------- Comment #4 from pault at gcc dot gnu dot org 2007-07-28 20:52 ------- (In reply to comment #3) Could somebody test the patch below, please? Paul Index: gcc/fortran/trans-stmt.c =================================================================== *** gcc/fortran/trans-stmt.c (revision 127010) --- gcc/fortran/trans-stmt.c (working copy) *************** generate_loop_for_temp_to_lhs (gfc_expr *** 1714,1719 **** --- 1714,1720 ---- stmtblock_t block, body; gfc_loopinfo loop1; tree tmp; + tree falselhs; tree wheremaskexpr; /* Walk the lhs. */ *************** generate_loop_for_temp_to_lhs (gfc_expr *** 1732,1737 **** --- 1733,1741 ---- tmp = gfc_build_array_ref (tmp1, count1); /* Use the scalar assignment as is. */ + 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); gfc_add_modify_expr (&block, lse.expr, tmp); gfc_add_block_to_block (&block, &lse.post); *************** gfc_trans_where_assign (gfc_expr *expr1, *** 2978,2984 **** /* Use the scalar assignment as is. */ if (sym == NULL) tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, ! loop.temp_ss != NULL, false); else tmp = gfc_conv_operator_assign (&lse, &rse, sym); --- 2982,2989 ---- /* Use the scalar assignment as is. */ if (sym == NULL) tmp = gfc_trans_scalar_assign (&lse, &rse, expr1->ts, ! loop.temp_ss != NULL, ! expr2->expr_type == EXPR_VARIABLE); else tmp = gfc_conv_operator_assign (&lse, &rse, sym); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32795