From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3781 invoked by alias); 9 Jun 2011 22:23:24 -0000 Received: (qmail 3771 invoked by uid 22791); 9 Jun 2011 22:23:23 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 09 Jun 2011 22:23:10 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49324] Deep copy missing for array constructors of DT w/ allocatable components X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: major X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 09 Jun 2011 22:23:00 -0000 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: 2011-06/txt/msg00811.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49324 --- Comment #5 from Tobias Burnus 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) {