In assignments, such as
  string = trim(string)
  string(n1:n2) = trim(string)
the trim has no effect and can be optimized away.

(Note: With Fortran 2003 and allocatable strings with "len=:", the first
version cannot be optimized as on length mismatch the LHS is reallocated.)

Such code can easily be present in real-world code and causes unnecessarily a
large overhead, cf. e.g. http://www.tddft.org/trac/octopus/changeset/5672


-- 
           Summary: Assignment using "= trim(string)": Optimize "trim" away
           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: burnus at gcc dot gnu dot org


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

Reply via email to