From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23959 invoked by alias); 25 Oct 2010 21:45:27 -0000 Received: (qmail 23947 invoked by uid 22791); 25 Oct 2010 21:45:27 -0000 X-SWARE-Spam-Status: No, hits=-2.6 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; Mon, 25 Oct 2010 21:45:23 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46174] New: [OOP] ALLOCATE with SOURCE: Deep copy missing X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 25 Oct 2010 21:45: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: 2010-10/txt/msg02095.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46174 Summary: [OOP] ALLOCATE with SOURCE: Deep copy missing Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: janus@gcc.gnu.org The following is in a sense a follow up to PR 45451. Assuming that X and Y are both polymorphic (CLASS) and the following operation: ALLOCATE (x, SOURCE=y) or x = y ! Fortran 2008: (Re)alloc on assignment with polymorphic LHS In those cases, one might need to do a deep copy as the polymorphic item might have allocatable components. This currently does not work. Example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 11 12 13 14 15 16 17 18 19 20 Aborted (core dumped) The third line should be the same as the first one - but in reality it still points to the allocatable components of the SOURCE=. implicit none type t end type t type, extends(t) :: t2 integer, allocatable :: a(:) end type t2 class(t), allocatable :: x, y integer :: i allocate(t2 :: x) select type(x) type is (t2) allocate(x%a(10)) x%a = [ (i, i = 1,10) ] print '(*(i3))', x%a class default call abort() end select allocate(y, source=x) select type(x) type is (t2) x%a = [ (i, i = 11,20) ] print '(*(i3))', x%a class default call abort() end select select type(y) type is (t2) print '(*(i3))', y%a if (any (y%a /= [ (i, i = 1,10) ])) call abort() class default call abort() end select end