public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fxcoudert at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code
Date: Wed, 06 Nov 2013 19:52:00 -0000	[thread overview]
Message-ID: <bug-59026-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 59026
           Summary: ELEMENTAL procedure with VALUE arguments emits wrong
                    code
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fxcoudert at gcc dot gnu.org

The following source is compiled into wrong code:

interface
  elemental integer function foo(x)
    integer, intent(in), value :: x
  end function
end interface

  print *, foo(42)
  print *, foo([0,1])
end

For all versions of gfortran starting from 4.3 (and up to current trunk), the
second call to FOO is miscompiled. Looking at the generated code
(-fdump-tree-original), the first call is, as expected, by value:

      D.1882 = foo (42);
      _gfortran_transfer_integer_write (&dt_parm.0, &D.1882, 4);

while the second call is by-reference:

              D.1887 = A.2[S.3];
              D.1888 = foo (&D.1887);
              _gfortran_transfer_integer_write (&dt_parm.1, &D.1888, 4);

This can be confirmed by adding an actual FOO function such as:

elemental integer function foo(x)
  integer, intent(in), value :: x
  foo = x - 1
end function

Running the complete program then yields:

          41
  1370438451  1370438451


             reply	other threads:[~2013-11-06 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-06 19:52 fxcoudert at gcc dot gnu.org [this message]
2013-11-06 20:58 ` [Bug fortran/59026] " pault at gcc dot gnu.org
2014-02-09 19:45 ` pault at gcc dot gnu.org
2014-06-07 10:23 ` fxcoudert at gcc dot gnu.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-59026-4@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).