[Bug fortran/27662] Transpose doesn't work on function return
kargl at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Thu May 18 20:42:00 GMT 2006
------- Comment #2 from kargl at gcc dot gnu dot org 2006-05-18 20:41 -------
Actually, transpose by itself does the right thing. It is the
combination of matmul and transpose that is screwing up indexing.
A slightly modified version of your program gives
troutmask:kargl[290] ./z
1.0 0.0 0.0 1.0 <-- x
1.0 0.0 0.0 1.0 <-- a = test()
1.0 0.0 0.0 1.0 <-- a = transpose(test())
1.0 0.0 0.0 1.0 <-- z = matmul(x,a)
1.0 0.0 1.0 0.0 <-- z = matmul(x,transpose(test()))
Abort (core dumped)
Here the program.
program foo
implicit none
real(kind=kind(1.0d0)), dimension(2, 2):: x, z, a
integer i, j
x(1,1) = 1.d0
x(2,1) = 0.d0
x(1,2) = 0.d0
x(2,2) = 1.d0
!
! Uncomment to see the output.
!
print '(4F4.1,1X,A)', x(1,1), x(2,1), x(1,2), x(2,2), '<-- x'
a = test()
print '(4F4.1,1X,A)', a(1,1), a(2,1), a(1,2), a(2,2), '<-- a = test()'
a = transpose(test())
print '(4F4.1,1X,A)', a(1,1), a(2,1), a(1,2), a(2,2), &
& '<-- a = transpose(test())'
z = matmul(x, a)
print '(4F4.1,1X,A)', z(1,1), z(2,1), z(1,2), z(2,2), '<-- z = matmul(x,a)'
z = matmul(x, transpose(test()))
print '(4F4.1,1X,A)', z(1,1), z(2,1), z(1,2), z(2,2), &
& '<-- z = matmul(x,transpose(test()))'
z = matmul(x, transpose(test()))
do i = 1, 2
do j = 1, 2
if (x(i,j) .ne. z(i,j)) call abort()
end do
end do
close (10)
contains
function test() result (res)
real(kind=kind(1.0d0)), dimension(2,2) :: res
res(1,1) = 1.d0
res(2,1) = 0.d0
res(1,2) = 0.d0
res(2,2) = 1.d0
end function
end
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-05-18 20:41:45
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27662
More information about the Gcc-bugs
mailing list