This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/55072] New: [4.5/4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Oct 2012 09:22:29 +0000
- Subject: [Bug fortran/55072] New: [4.5/4.6/4.7/4.8 Regression] Missing internal_pack leads to wrong code with derived type
- Auto-submitted: auto-generated
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