This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/44582] New: Gfotran generates wrong results due to wrong ABI in function with array return
- From: "yin at absoft dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jun 2010 18:15:48 -0000
- Subject: [Bug fortran/44582] New: Gfotran generates wrong results due to wrong ABI in function with array return
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
the function with array return must create a temporary array to hold the
returned value and transfer the value to destination array after function call.
Gfortran directly pass the destination array as the first fake argument. This
is wrong because destination is supposed to assigned to a value from the call.
If the function does nothing to the return array. the destination array will
have a wrong value.
This is a example to show the bug
program sw
integer,parameter:: M=500,N=60
double precision,dimension(M,N,3):: u
double precision,dimension(M,N):: dudx
dudx(1,1) = 5.0
dudx = ddx(u(:,:,1))
contains
function ddx(array)
implicit double precision (a-h,o-z)
double precision:: array(:,:)
double precision:: ddx(size(array,dim=1),size(array,dim=2))
print *, ddx(1,1)
end function ddx
end program sw
gfortran returns 5.0
it should be 0.0 or a chaotic number.
--
Summary: Gfotran generates wrong results due to wrong ABI in
function with array return
Product: gcc
Version: fortran-dev
Status: UNCONFIRMED
Severity: critical
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yin at absoft dot com
GCC build triplet: x86-64
GCC host triplet: x86-64
GCC target triplet: x86-64
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44582