From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23774 invoked by alias); 20 May 2011 07:56:42 -0000 Received: (qmail 23748 invoked by uid 22791); 20 May 2011 07:56:39 -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; Fri, 20 May 2011 07:56:25 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy 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: Fri, 20 May 2011 08:01: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-05/txt/msg01667.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49076 Summary: ASSOCIATE: Array descriptor passed to explicit-shaped dummy 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: domob@gcc.gnu.org Reported by Andrew Baldwin at http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/b1ff1e3da48e6b27 The following program prints with gfortran: 3 4 3 4 33275912 0 With ifort 12 - and reportedly with NAG 5.2, it prints: 3 4 3 4 3 4 If one looks at the dump, one sees that in associated the function is called as: print_int (&bar); That's both the case for the explicit-shape "i(2)" and for an assumed-shape "i(:)". As "&bar" is the address of the descriptor, it works with assumed-shape arrays - and fails with assumed-size/explicit-size arrays. subroutine print_int (i) integer, intent (in) :: i(2) print *, i end subroutine print_int program main interface subroutine print_int (i) integer, intent (in) :: i(2) end subroutine print_int end interface integer, allocatable :: foo(:,:) allocate (foo(2,2)) foo(:,1) = [1, 2] foo(:,2) = [3, 4] call print_int (foo(:,2)) associate (bar => foo(:,2)) print *, bar call print_int (bar) end associate end program