From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29931 invoked by alias); 3 Feb 2012 07:49:10 -0000 Received: (qmail 29920 invoked by uid 22791); 3 Feb 2012 07:49:09 -0000 X-SWARE-Spam-Status: No, hits=-2.9 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; Fri, 03 Feb 2012 07:48:57 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52102] New: [OOP] Wrong result with ALLOCATE w/ SOURCE= and nonpoly. array constructor source-expr Date: Fri, 03 Feb 2012 07:49:00 -0000 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 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: 2012-02/txt/msg00315.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52102 Bug #: 52102 Summary: [OOP] Wrong result with ALLOCATE w/ SOURCE= and nonpoly. array constructor source-expr Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org The following program, which is an extension of testsuite/gfortran.dg/class_48.f90 and thus PR 51972 fails to correctly set the value via SOURCE: allocate (two%a(2), source=[t(4), t(6)]) Should give for two%a(1)%x and two%a(2)%x the values 4 and 6, but one gets 0 0. If one uses not a class component but a class variable, the result is 4 0. There is a similar PR for polymorphic sources, cf. PR 51864. subroutine test3 () type t integer :: x end type t type t2 class(t), allocatable :: a(:) end type t2 type(t2) :: one, two one = two if (allocated (one%a)) call abort () allocate (two%a(2), source=[t(4), t(6)]) one = two if (.not.allocated (one%a)) call abort () print *, one%a(1)%x print *, one%a(6)%x if ((one%a(1)%x /= 4)) call abort () if ((one%a(2)%x /= 6)) call abort () deallocate (two%a) one = two if (allocated (one%a)) call abort () end subroutine test3