public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/40551]  New: Wrong code due to missing copy-in/copy-out stried array to assumed-size dummy
Date: Thu, 25 Jun 2009 13:30:00 -0000	[thread overview]
Message-ID: <bug-40551-13404@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2009-06-25 13:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-25 13:30 burnus at gcc dot gnu dot org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-40551-13404@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).