[Bug fortran/52012] New: [4.6/4.7 Regression] Wrong-code with RESHAPE
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 26 23:14:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52012
Bug #: 52012
Summary: [4.6/4.7 Regression] Wrong-code with RESHAPE
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: critical
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: pault@gcc.gnu.org
The following program prints with GCC 4.6 and 4.7:
0.0000 0.0000 1.0000 0.0000 0.0000
0.0000 0.0000 0.0000
Expected: The following result - as with GCC 4.5:
0.0000 0.0000 1.0000 0.0000 0.0000
0.0000 0.0000 1.0000
Doing a simple print '(10f3.0)', a shows the correct result. Thus, depending
how one accesses an array element, the result is correct or wrong.
The issue was reported by Reinhold Bader; I added the abort checks (both fail).
program gf
implicit none
real, allocatable :: a(:,:,:)
! real :: a(5,4,3)
real :: b(3,4,5) = 0.0
b(1,2,3) = 1.0
allocate(a(size(b,3),size(b,2),size(b,1)))
a = reshape(b,shape(a),order=[3,2,1])
write(*,*) a(:,2,1)
! the following line prints an incorrect value of a(3,2,1)
! even though the above one works correctly
write(*,*) a(1,2,1), a(2,2,1), a(3,2,1)
if (a(3,2,1) /= 1) call abort()
if (sum(abs(a)) /= 1.0) call abort()
end program
More information about the Gcc-bugs
mailing list