This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran,patch] Fix zero-length substrings
- From: FX Coudert <fxcoudert at gmail dot com>
- To: "fortran at gcc dot gnu dot org List" <fortran at gcc dot gnu dot org>, patch patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 8 Jun 2006 23:13:32 +0200
- Subject: [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