From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18743 invoked by alias); 25 Oct 2012 09:22:45 -0000 Received: (qmail 18717 invoked by uid 48); 25 Oct 2012 09:22:30 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55072] New: [4.5/4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type Date: Thu, 25 Oct 2012 09:22: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-10/txt/msg02315.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55072 Bug #: 55072 Summary: [4.5/4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org The following code should print (and does so with GCC 4.1, 4.3 and 4.4): 1 9 3 11 1 9 3 11 However, starting from GCC 4.5, it prints: 1 9 3 11 1 5 9 13 The reason is that the passed pointer is not packed but directly passed (with array descriptor, which is not used): bar ((struct t[0:] *) p.data); while gfortran 4.4 correctly uses: D.1575 = _gfortran_internal_pack (&p); bar (D.1575); implicit none type t integer :: i end type t type(t), target :: tgt(4,4) type(t), pointer :: p(:,:) integer :: i,j,k k = 1 do i = 1, 4 do j = 1, 4 tgt(i,j)%i = k k = k+1 end do end do p => tgt(::2,::2) print *,p%i call bar(p) contains subroutine bar(x) type(t) :: x(*) print *,x(1:4)%i if (any (x(1:4)%i /= [1, 9, 3, 11])) call abort() end subroutine end