public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40551]  New: Wrong code due to missing copy-in/copy-out stried array to assumed-size dummy
@ 2009-06-25 13:30 burnus at gcc dot gnu dot org
  2009-06-25 13:32 ` [Bug fortran/40551] " burnus at gcc dot gnu dot org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-25 13:30 UTC (permalink / raw)
  To: gcc-bugs

Bug reported (with longer test case) by Maciej Zwierzycki
  at http://gcc.gnu.org/ml/fortran/2009-06/msg00254.html


The following program should produce  1   2 -42 -42
                      but it produces 1 -42   2 -42

For
  a(1,:) = func()
gfortran decides to pass result value by reference - and uses an array
descriptor for this (why?):
  func (struct array1_integer(kind=4) & __result)
and
  func (&parm.7);

However, as "func(2)" is an explicit-shaped array, it should be contiguous and
thus for "call sub(func)" simply the address is passed, ignoring the stride:

  sub ((integer(kind=4)[0:] *) parm.4.data);

At some place the copy-in/copy-out must happen. Actually, I had assumed that
already the call to "func" would cause a temporary be created. That's actually
what happens in case of g95:
  SC1 = *func_ ();;

Test case:


integer :: a(2,2)
a = -42
a(1,:) = func()
print *,a
contains
 function func()
   integer :: func(2)
   call sub(func)
 end function func
 subroutine sub(a)
   integer :: a(2)
   a = [1,2]
 end subroutine
end


-- 
           Summary: Wrong code due to missing copy-in/copy-out stried array
                    to assumed-size dummy
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: major
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 40443
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40551


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

end of thread, other threads:[~2009-07-09 17:11 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-25 13:30 [Bug fortran/40551] New: Wrong code due to missing copy-in/copy-out stried array to assumed-size dummy burnus at gcc dot gnu dot org
2009-06-25 13:32 ` [Bug fortran/40551] " burnus at gcc dot gnu dot org
2009-06-25 14:22 ` dominiq at lps dot ens dot fr
2009-06-25 15:06 ` burnus at gcc dot gnu dot org
2009-06-25 15:43 ` burnus at gcc dot gnu dot org
2009-06-25 16:05 ` burnus at gcc dot gnu dot org
2009-06-28 20:31 ` pault at gcc dot gnu dot org
2009-06-29  9:21 ` pault at gcc dot gnu dot org
2009-06-29 15:19 ` pault at gcc dot gnu dot org
2009-06-29 20:39 ` pault at gcc dot gnu dot org
2009-06-30  6:24 ` pault at gcc dot gnu dot org
2009-07-05 19:06 ` pault at gcc dot gnu dot org
2009-07-07 12:47 ` burnus at gcc dot gnu dot org
2009-07-07 15:27 ` burnus at gcc dot gnu dot org
2009-07-09 17:06 ` [Bug fortran/40551] Optimizations possible using gfc_full_array_ref_p pault at gcc dot gnu dot org
2009-07-09 17:11 ` 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).