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

Reply via email to