Another case that doesn't need a temp:

MODULE M1
  PRIVATE
  REAL, PARAMETER :: c(2)=(/(i,i=1,2)/)
CONTAINS
  ! OK
  SUBROUTINE S0
    real :: r
     r=0
     r=S2(c)
  END SUBROUTINE S0
  ! NOT OK
  SUBROUTINE S1
    real :: r
     r=0
     r=r+S2(c)
  END SUBROUTINE S1

  FUNCTION S2(c)
     REAL, INTENT(IN) :: c(2)
     s2=0
  END FUNCTION S2
END MODULE M1

In S1, somehow it seems that 'c' is being packed if S2 is part of an expression


-- 
           Summary: unneeded temporary (s=s+f(a))
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


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

Reply via email to