From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21540 invoked by alias); 23 Nov 2011 16:36:01 -0000 Received: (qmail 21301 invoked by uid 22791); 23 Nov 2011 16:35:58 -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; Wed, 23 Nov 2011 16:35:44 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/51284] New: [OOP] CLASS and VALUE attribute: No copy to temporary done Date: Wed, 23 Nov 2011 16:44: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: 2011-11/txt/msg02332.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51284 Bug #: 51284 Summary: [OOP] CLASS and VALUE attribute: No copy to temporary done 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 CC: janus@gcc.gnu.org The following program fails in several ways. As written, the program fails as "test" modifies the value of a%i - but it shouldn't: "A present dummy argument with the VALUE attribute becomes argument associated with a definable anonymous data object whose initial value is the value of the actual argument." (12.5.2.3 Argument association). If one uncomments "test2", it fails with: Error: VALUE attribute conflicts with DIMENSION attribute at (1) However, in Fortran 2008 this restriction is not present: C557 An entity with the VALUE attribute shall be a dummy data object that is not an assumed-size array or a coarray, and does not have a coarray ultimate component. C558 An entity with the VALUE attribute shall not have the ALLOCATABLE, INTENT (INOUT), INTENT (OUT), POINTER, or VOLATILE attributes. Additionally, with the current polymorphic array draft patch the b(:)%i (in "b(:)%i = 8" and "any(b(:)%i /= 8") causes an ICE (segfault). Doing a "do i=1,8; b(i)%i = 8; done" had a similar problem. Finally, I think polymorphic arrays suffer from the same issue as scalar polymorphic arrays. Note: A deep copy has to be done, which takes the allocatable components into account. module m type t integer :: i end type t contains subroutine test(x) class(t), VALUE :: x x%i = 5 end subroutine test ! subroutine test2(x) ! class(t), VALUE :: x(:) ! x(:)%i = 99 ! end subroutine test2 end module m use m class(t), allocatable :: a, b(:) allocate ( t :: a, b(5)) a%i = 2 !b(:)%i = 8 call test(a) !call test2(b) if (a%i /= 2) call abort () !if (any(b(:)%i /= 8)) call abort () end