This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/52117] New: allocated arrays give incorrect results when used with RESHAPE in gcc v4.6.2
- From: "sphirshman at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 03 Feb 2012 20:32:19 +0000
- Subject: [Bug fortran/52117] New: allocated arrays give incorrect results when used with RESHAPE in gcc v4.6.2
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52117
Bug #: 52117
Summary: allocated arrays give incorrect results when used with
RESHAPE in gcc v4.6.2
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sphirshman@yahoo.com
This snippet of code gives incorrect results for the reshaped array. If the
arrays are NOT allocated, but explicitly dimensioned, the correct result is
obtained.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
PROGRAM RESHAPEIT
INTEGER, PARAMETER :: n1=2, n2=2, n3=2
INTEGER :: m1, m2, m3, lc
REAL, ALLOCATABLE :: A(:,:), B(:,:,:)
REAL :: val
ALLOCATE (A(n1,n2*n3), B(n1,n2,n3))
! INITIALIZE A
val = 0
lc = 0
DO m3=1,n3
DO m2=1,n2
lc = lc+1
DO m1=1,n1
val = val+1
A(m1, lc) = val
END DO
END DO
END DO
B = RESHAPE(A, SHAPE(B))
lc = 0
DO m3=1,n3
DO m2=1,n2
lc = lc+1
DO m1=1,n1
PRINT *,'A(',m1,',',lc,') = ',A(m1,lc),' B = ',B(m1,m2,m3)
END DO
END DO
END DO
DEALLOCATE(A, B)
PAUSE
END PROGRAM RESHAPEIT
++++++++++++++++++++++++++++++++++++++++++++++++++++++