[Bug fortran/32795] allocatable components are nullified prematurely

pault at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Jul 28 20:52:00 GMT 2007



------- 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



More information about the Gcc-bugs mailing list