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/53642] New: Front-end optimization: Wrong string length for deferred-length strings


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

             Bug #: 53642
           Summary: Front-end optimization: Wrong string length for
                    deferred-length strings
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: damian@rouson.net, tkoenig@gcc.gnu.org


As reported by Damian Rouson at
http://gcc.gnu.org/ml/fortran/2012-06/msg00069.html

Without optimization, the following program prints - and should print:
           3           3

However, with -ffrontend-optimize the result is, wrongly,
           3           4

Damian: Use -fno-frontend-optimize as work-around.

character(len=4) :: string="123 "
character(:), allocatable :: trimmed
trimmed = trim(string)
print *,len_trim(string),len(trimmed)
end


>From the original dump:

(a) Without FE optimization
        _gfortran_string_trim (&len.1, (void * *) &pstr.0, 4, &string);
        D.1864 = len.1;
        if (trimmed != 0B) goto L.1;
        trimmed = (character(kind=1)[1:.trimmed] *)
                       __builtin_malloc ((sizetype) len.1);
        ...
        .trimmed = len.1;

(b) With FE optimization
        if (trimmed != 0B) goto L.1;
        trimmed = (character(kind=1)[1:.trimmed] *) __builtin_malloc (4);
        ...
        .trimmed = 4;


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