Found when looking at PR fortran/36158

If the argument is an initialization expression and not too large, it should be
expanded. While the following works:
  real, parameteR :: bes(2) = bessel_jn([1,2], 1.0)
  print *, bes
  end

The "if" is never optimized away for:

if (any (abs(bessel_jn([1,2], 1.0) - bessel_jn([1,2], 1.0)) &
         > epsilon(0.0))) &
  call I_do_not_exist()

if (any (abs(bessel_jn(1, 2, 1.0) - bessel_jn([1,2], 1.0)) &
         > epsilon(0.0))) &
  call I_do_not_exist()
end

such that one gets linkage errors:
  test.f90:(.text+0x8e): undefined reference to `i_do_not_exist_'
  test.f90:(.text+0x108): undefined reference to `i_do_not_exist_'


-- 
           Summary: Array-valued calles to elementals are not simplified
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to