public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/44582]  New: Gfotran generates wrong results due to wrong ABI in function with array return
@ 2010-06-18 18:16 yin at absoft dot com
  2010-06-18 18:17 ` [Bug fortran/44582] " yin at absoft dot com
                   ` (20 more replies)
  0 siblings, 21 replies; 22+ messages in thread
From: yin at absoft dot com @ 2010-06-18 18:16 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2010-07-16  4:49 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-18 18:16 [Bug fortran/44582] New: Gfotran generates wrong results due to wrong ABI in function with array return yin at absoft dot com
2010-06-18 18:17 ` [Bug fortran/44582] " yin at absoft dot com
2010-06-18 18:23 ` yin at absoft dot com
2010-06-18 18:50 ` [Bug fortran/44582] gfortran " kargl at gcc dot gnu dot org
2010-06-18 19:00 ` yin at absoft dot com
2010-06-18 19:11 ` kargl at gcc dot gnu dot org
2010-06-19  9:48 ` burnus at gcc dot gnu dot org
2010-06-19 12:30 ` pault at gcc dot gnu dot org
2010-06-19 14:55 ` pault at gcc dot gnu dot org
2010-06-19 16:42 ` pault at gcc dot gnu dot org
2010-06-20 17:46 ` pault at gcc dot gnu dot org
2010-06-20 18:31 ` burnus at gcc dot gnu dot org
2010-06-20 20:10 ` dominiq at lps dot ens dot fr
2010-06-22  4:37 ` paul dot richard dot thomas at gmail dot com
2010-06-22  5:47 ` burnus at gcc dot gnu dot org
2010-06-27 16:17 ` pault at gcc dot gnu dot org
2010-06-27 16:34 ` pault at gcc dot gnu dot org
2010-06-28  6:47 ` paul dot richard dot thomas at gmail dot com
2010-06-29 18:58 ` pault at gcc dot gnu dot org
2010-06-29 19:04 ` pault at gcc dot gnu dot org
2010-07-10 17:09 ` pault at gcc dot gnu dot org
2010-07-16  4:49 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).