This is the mail archive of the gcc-patches@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]

[gfortran,patch] Fix zero-length substrings


:ADDPATCH fortran:

Attached (almost "obvious") patch fixes PR fortran/27958, which is about zero-length substrings not being handled correctly. We used to generate strings with negative length (for example, for string(5:2)) instead of zero-length, which isn't properly understood by libgfortran functions, and gives error in simplification routines (for example, len(string(5:2)) is simplified into -3).

The patch sets substring length to zero if it is computed (from the start and end bounds) to be negative, fixing all these problems. I also added a check to avoid calls to _gfortran_copy_string when the destination length is zero, for example: d(5:4) = "foobar".

Regtested on i686-linux, it comes with a testcase that failed in various places before the patch. OK for mainline and 4.1?

Thanks,
FX


Attachment: substring.ChangeLog
Description: Binary data

Attachment: substring.diff
Description: Binary data


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