This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR67721 deep copy missing when assigning derived type constructor to an array


Hello,

I've just submitted this PR, and the patch as well, which passes the testsuite.

The problem is a missing deep copy when the rhs is a (scalar) derived type constructor (with allocatable components) and the lhs an array. The patch removes the nonconstantness condition, so that the deep_copy flag passed to gfc_trans_scalar_assign is set to true.

Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
Mikael

Attachment: pr67721_v1.CL
Description: Text document

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index cfa1a71..e086fe3 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -9232,7 +9232,6 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
   scalar_to_array = (expr2->ts.type == BT_DERIVED
 		       && expr2->ts.u.derived->attr.alloc_comp
 		       && !expr_is_variable (expr2)
-		       && !gfc_is_constant_expr (expr2)
 		       && expr1->rank && !expr2->rank);
   scalar_to_array |= (expr1->ts.type == BT_DERIVED
 				    && expr1->rank

Attachment: alloc_comp_deep_copy_3.f03
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]