This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gfortran,patch] Don't evaluate substring bounds multiple times
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "gfortran List" <fortran at gcc dot gnu dot org>, "gcc-patches List" <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 7 May 2007 10:10:36 +0200
- Subject: Re: [gfortran,patch] Don't evaluate substring bounds multiple times
- References: <F3B34F0C-7334-4135-91CB-7BC3005E6F30@gmail.com>
Hi all,
Please find attached an amended version of this patch. The first one
created a missed-optimization in references such as string(i:i), which
wasn't recognized as a one-character string any more (breaking
testcase gfortran.dg/single_char_string.f90 [1]). The new version of
the patch avoids calling gfc_evaluate_now() if the start or end bound
is a reference to a variable.
Bootstrapped and regtested on i686-linux, OK for mainline? OK for 4.2?
(the backport is trivial and with low risk, that part of the front-end
hasn't changed since branching; I'd go for it myself, but wanted to
ask for opinions here)
FX
2007-05-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31725
* trans-expr.c (gfc_conv_substring): Evaluate substring bounds
only once.
2007-05-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/31725
* gfortran.dg/substr_4.f: New test.
Attached patch fixes PR31725: we currently evaluate multiple times
the bounds of a substring, which of course leads to nasty wrong-code
bugs when said bounds have side effects. This simple two-lines patch
Bootstrapped && regtested on i686-linux, comes with a testcase from
the PR. OK for mainline? Is that nasty enough that we want to
backport it to 4.2? (the backport is trivial and with low risk, that
part of the front-end hasn't changed since branching; I'd go for it
myself, but wanted to ask for opinions here)