public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code
@ 2013-11-06 19:52 fxcoudert at gcc dot gnu.org
  2013-11-06 20:58 ` [Bug fortran/59026] " pault at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2013-11-06 19:52 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug fortran/59026] ELEMENTAL procedure with VALUE arguments emits wrong code
  2013-11-06 19:52 [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code fxcoudert at gcc dot gnu.org
@ 2013-11-06 20:58 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: pault at gcc dot gnu.org @ 2013-11-06 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-06
                 CC|                            |pault at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 31176
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31176&action=edit
Fixes the PR

This is regtesting right now - I'll prepare the testcase and submit, as soon as
it is done.

Best regards

Paul


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

* [Bug fortran/59026] ELEMENTAL procedure with VALUE arguments emits wrong code
  2013-11-06 19:52 [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code fxcoudert at gcc dot gnu.org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pault at gcc dot gnu.org @ 2014-02-09 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Feb  9 19:45:06 2014
New Revision: 207645

URL: http://gcc.gnu.org/viewcvs?rev=207645&root=gcc&view=rev
Log:
2014-02-09  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/59026
    * trans-expr.c (gfc_conv_procedure_call): Pass the value of the
    actual argument to a formal argument with the value attribute
    in an elemental procedure.

2014-02-09  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/59026
    * gfortran.dg/elemental_by_value_1.f90 : New test

Added:
    trunk/gcc/testsuite/gfortran.dg/elemental_by_value_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/59026] ELEMENTAL procedure with VALUE arguments emits wrong code
  2013-11-06 19:52 [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code fxcoudert at gcc dot gnu.org
  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
  2 siblings, 0 replies; 4+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2014-06-07 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Was fixed on 4.9, not a regression: closing.


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

end of thread, other threads:[~2014-06-07 10:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06 19:52 [Bug fortran/59026] New: ELEMENTAL procedure with VALUE arguments emits wrong code fxcoudert at gcc dot gnu.org
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

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).