This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/55069] New: [4.7/4.8 Regression] TRIM incorrectly optimized out for assignment to allocatable string


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

             Bug #: 55069
           Summary: [4.7/4.8 Regression] TRIM incorrectly optimized out
                    for assignment to allocatable string
    Classification: Unclassified
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: quantheory@gmail.com


With -ffrontend-optimize turned on, in the following assignments, "str" is
allocated to a larger size than it should have:

  character(len=2) :: blah
  character(len=:), allocatable :: str

  blah = "a"

  ! With -O, str will be set to "a ", else str == "a"
  str = trim(blah)

  ! No effect with -O
  str = trim(str)

  ! With -O str will be set to "ba ", else "ba"
  str = "b"//trim(blah)

  ! This trim cannot be optimized out, so it yields "ab" either way.
  str = trim(blah)//"b"


This problem with allocatable strings is noted in the original enhancement
proposal (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40628), but apparently
not addressed yet?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]