public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43841]  New: Missing temporary for ELEMENTAL function call
@ 2010-04-21 19:54 anlauf at gmx dot de
  2010-04-21 20:49 ` [Bug fortran/43841] " dominiq at lps dot ens dot fr
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: anlauf at gmx dot de @ 2010-04-21 19:54 UTC (permalink / raw)
  To: gcc-bugs

As reported in

http://gcc.gnu.org/ml/fortran/2010-04/msg00215.html

gfortran does not always produce a temporary when it deems necessary.

Reduce testcase:

program main
  implicit none

  type::polar_t
     real :: l
  end type polar_t

  call test_member
contains

  subroutine test_member
    type(polar_t),dimension(2)::b

    b    = polar_t(2.0)
    b(:) = div_pp (b(:), b(1))
    write(*,*) b
    if (b(2)%l /= 1) call abort ()
  end subroutine test_member

  elemental function div_pp(u,v) result(o)
    type(polar_t),intent(in)::u,v
    type(polar_t)           ::o
    o%l  = u%l / v%l
  end function div_pp

end program main

Result with gfortran:
% ./a.out
   1.0000000       2.0000000
Aborted

Expected result:
   1.000000       1.000000


-- 
           Summary: Missing temporary for ELEMENTAL function call
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: anlauf at gmx dot de


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
@ 2010-04-21 20:49 ` dominiq at lps dot ens dot fr
  2010-04-21 21:52 ` dominiq at lps dot ens dot fr
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-04-21 20:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dominiq at lps dot ens dot fr  2010-04-21 20:48 -------
Confirmed. The test fails with gfortran from at least 4.2.3 up to trunk.


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
  2010-04-21 20:49 ` [Bug fortran/43841] " dominiq at lps dot ens dot fr
@ 2010-04-21 21:52 ` dominiq at lps dot ens dot fr
  2010-04-22  7:28 ` anlauf at gmx dot de
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dominiq at lps dot ens dot fr @ 2010-04-21 21:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from dominiq at lps dot ens dot fr  2010-04-21 21:51 -------
PR43843 looks like a duplicate.


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
  2010-04-21 20:49 ` [Bug fortran/43841] " dominiq at lps dot ens dot fr
  2010-04-21 21:52 ` dominiq at lps dot ens dot fr
@ 2010-04-22  7:28 ` anlauf at gmx dot de
  2010-04-22  8:25 ` dfranke at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: anlauf at gmx dot de @ 2010-04-22  7:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from anlauf at gmx dot de  2010-04-22 07:27 -------
(In reply to comment #2)
> PR43843 looks like a duplicate.

It is.  I simply reduced the program in the mail to a testcase.


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (2 preceding siblings ...)
  2010-04-22  7:28 ` anlauf at gmx dot de
@ 2010-04-22  8:25 ` dfranke at gcc dot gnu dot org
  2010-04-22  8:28 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-04-22  8:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dfranke at gcc dot gnu dot org  2010-04-22 08:25 -------
*** Bug 43843 has been marked as a duplicate of this bug. ***


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (3 preceding siblings ...)
  2010-04-22  8:25 ` dfranke at gcc dot gnu dot org
@ 2010-04-22  8:28 ` burnus at gcc dot gnu dot org
  2010-04-22 20:01 ` pault at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-04-22  8:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2010-04-22 08:28 -------
>From PR 43843:

Reported by Kyle Horne at http://gcc.gnu.org/ml/fortran/2010-04/msg00215.html

There is a missing temporary for user-defined operators:

   type(polar_t),dimension(3)::b
   b = polar_t(1.0,0.5)
   b(:) = b(:)/b(1)

The latter is translated into:
    struct polar_t * D.1551;
    D.1551 = &b[0];

      S.5 = 1;
      while (1)
        {
          if (S.5 > 3) goto L.3;
          b[S.5 + -1] = div_pp (&b[S.5 + -1], D.1551);
          S.5 = S.5 + 1;
        }
      L.3:;

but that fails as one overrides *D.1551 alias b[0] alias B(1) in the first
iteration instead of evaluating first all of the RHS before assigning to the
LHS.

Work with ifort and NAG, fails with GCC 4.1, 4.2, 4.3, 4.4, 4.5, and 4.6


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-04-22 08:28:12
               date|                            |


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (4 preceding siblings ...)
  2010-04-22  8:28 ` burnus at gcc dot gnu dot org
@ 2010-04-22 20:01 ` pault at gcc dot gnu dot org
  2010-04-23  8:13 ` pault at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-04-22 20:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2010-04-22 20:01 -------
(In reply to comment #5)

>     struct polar_t * D.1551;
>     D.1551 = &b[0];
> 
>       S.5 = 1;
>       while (1)
>         {
>           if (S.5 > 3) goto L.3;
>           b[S.5 + -1] = div_pp (&b[S.5 + -1], D.1551);
>           S.5 = S.5 + 1;
>         }
>       L.3:;
> 

The temporary is being generated but it needs dereferencing !!! ie. It would be
nice if:
>     struct polar_t  D.1551;
>     D.1551 = b[0];
> 
>       S.5 = 1;
>       while (1)
>         {
>           if (S.5 > 3) goto L.3;
>           b[S.5 + -1] = div_pp (&b[S.5 + -1], &D.1551);
>           S.5 = S.5 + 1;
>         }
>       L.3:;
> 

were happening.

Paul

I'm looking at it.

Paul


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (5 preceding siblings ...)
  2010-04-22 20:01 ` pault at gcc dot gnu dot org
@ 2010-04-23  8:13 ` pault at gcc dot gnu dot org
  2010-04-24  7:44 ` pault at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-04-23  8:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2010-04-23 08:12 -------
I posted a fix this morning.

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
           Keywords|                            |wrong-code
   Last reconfirmed|2010-04-22 08:28:12         |2010-04-23 08:12:46
               date|                            |


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (6 preceding siblings ...)
  2010-04-23  8:13 ` pault at gcc dot gnu dot org
@ 2010-04-24  7:44 ` pault at gcc dot gnu dot org
  2010-04-24  9:29 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-04-24  7:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pault at gcc dot gnu dot org  2010-04-24 07:44 -------
(In reply to comment #7)
> I posted a fix this morning.
...which gives,

  {
    struct polar_t D.1625;

    D.1625 = b[0];
    {
      integer(kind=8) S.18;

      S.18 = 1;
      while (1)
        {
          if (S.18 > 3) goto L.15;
          b[S.18 + -1] = div_pp (&b[S.18 + -1], &D.1625);
          S.18 = S.18 + 1;
        }
      L.15:;
    }
  }


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (7 preceding siblings ...)
  2010-04-24  7:44 ` pault at gcc dot gnu dot org
@ 2010-04-24  9:29 ` pault at gcc dot gnu dot org
  2010-05-25 21:02 ` mikael at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-04-24  9:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2010-04-24 09:28 -------
Subject: Bug 43841

Author: pault
Date: Sat Apr 24 09:28:32 2010
New Revision: 158683

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158683
Log:
2010-04-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * trans-expr.c (gfc_conv_expr): Supply an address expression for
        GFC_SS_REFERENCE.
        (gfc_conv_expr_reference): Call gfc_conv_expr and return for
        GFC_SS_REFERENCE.
        * trans-array.c (gfc_add_loop_ss_code): Store the value rather
        than the address of a GFC_SS_REFERENCE.
        * trans.h : Change comment on GFC_SS_REFERENCE. 

2010-04-24  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * gfortran.dg/elemental_scalar_args_1.f90 : New test.


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


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (8 preceding siblings ...)
  2010-04-24  9:29 ` pault at gcc dot gnu dot org
@ 2010-05-25 21:02 ` mikael at gcc dot gnu dot org
  2010-06-24 15:44 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: mikael at gcc dot gnu dot org @ 2010-05-25 21:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from mikael at gcc dot gnu dot org  2010-05-25 21:02 -------
Any backport ?


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (9 preceding siblings ...)
  2010-05-25 21:02 ` mikael at gcc dot gnu dot org
@ 2010-06-24 15:44 ` pault at gcc dot gnu dot org
  2010-06-27 16:15 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-06-24 15:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from pault at gcc dot gnu dot org  2010-06-24 15:44 -------
(In reply to comment #10)
> Any backport ?
> 

Ah yes, thanks, Mikael....

I have drawn up a list of PRs for which I have fixes but have not made commits.
 I'll try to get through them next week.

Paul


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (10 preceding siblings ...)
  2010-06-24 15:44 ` pault at gcc dot gnu dot org
@ 2010-06-27 16:15 ` pault at gcc dot gnu dot org
  2010-06-27 16:22 ` pault at gcc dot gnu dot org
  2010-06-27 16:24 ` pault at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-06-27 16:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pault at gcc dot gnu dot org  2010-06-27 16:15 -------
Subject: Bug 43841

Author: pault
Date: Sun Jun 27 16:14:55 2010
New Revision: 161471

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161471
Log:
2010-06-27  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * trans-expr.c (gfc_conv_expr): Supply an address expression for
        GFC_SS_REFERENCE.
        (gfc_conv_expr_reference): Call gfc_conv_expr and return for
        GFC_SS_REFERENCE.
        * trans-array.c (gfc_add_loop_ss_code): Store the value rather
        than the address of a GFC_SS_REFERENCE.
        * trans.h : Change comment on GFC_SS_REFERENCE. 

2010-06-27  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * gfortran.dg/elemental_scalar_args_1.f90 : New test.


Added:
   
branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/elemental_scalar_args_1.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/trans-array.c
    branches/gcc-4_5-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_5-branch/gcc/fortran/trans.h
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (11 preceding siblings ...)
  2010-06-27 16:15 ` pault at gcc dot gnu dot org
@ 2010-06-27 16:22 ` pault at gcc dot gnu dot org
  2010-06-27 16:24 ` pault at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-06-27 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from pault at gcc dot gnu dot org  2010-06-27 16:22 -------
Subject: Bug 43841

Author: pault
Date: Sun Jun 27 16:22:27 2010
New Revision: 161472

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161472
Log:
2010-06-27  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * trans-expr.c (gfc_conv_expr): Supply an address expression for
        GFC_SS_REFERENCE.
        (gfc_conv_expr_reference): Call gfc_conv_expr and return for
        GFC_SS_REFERENCE.
        * trans-array.c (gfc_add_loop_ss_code): Store the value rather
        than the address of a GFC_SS_REFERENCE.
        * trans.h : Change comment on GFC_SS_REFERENCE. 

2010-06-27  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43841
        PR fortran/43843
        * gfortran.dg/elemental_scalar_args_1.f90 : New test.


Added:
   
branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/elemental_scalar_args_1.f90
Modified:
    branches/gcc-4_4-branch/gcc/fortran/ChangeLog
    branches/gcc-4_4-branch/gcc/fortran/trans-array.c
    branches/gcc-4_4-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_4-branch/gcc/fortran/trans.h
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/43841] Missing temporary for ELEMENTAL function call
  2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
                   ` (12 preceding siblings ...)
  2010-06-27 16:22 ` pault at gcc dot gnu dot org
@ 2010-06-27 16:24 ` pault at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-06-27 16:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from pault at gcc dot gnu dot org  2010-06-27 16:24 -------
Fixed and backported to 4.4 and 4.5

Thanks for the report

Paul


-- 

pault at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2010-06-27 16:24 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-21 19:54 [Bug fortran/43841] New: Missing temporary for ELEMENTAL function call anlauf at gmx dot de
2010-04-21 20:49 ` [Bug fortran/43841] " dominiq at lps dot ens dot fr
2010-04-21 21:52 ` dominiq at lps dot ens dot fr
2010-04-22  7:28 ` anlauf at gmx dot de
2010-04-22  8:25 ` dfranke at gcc dot gnu dot org
2010-04-22  8:28 ` burnus at gcc dot gnu dot org
2010-04-22 20:01 ` pault at gcc dot gnu dot org
2010-04-23  8:13 ` pault at gcc dot gnu dot org
2010-04-24  7:44 ` pault at gcc dot gnu dot org
2010-04-24  9:29 ` pault at gcc dot gnu dot org
2010-05-25 21:02 ` mikael at gcc dot gnu dot org
2010-06-24 15:44 ` pault at gcc dot gnu dot org
2010-06-27 16:15 ` pault at gcc dot gnu dot org
2010-06-27 16:22 ` pault at gcc dot gnu dot org
2010-06-27 16:24 ` 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).