[PATCH] Fix PR middle-end/26001, expand messing up the index for a string constant

Andrew Pinski pinskia@physics.uc.edu
Tue Jan 31 14:34:00 GMT 2006


The problem here is that expand when tries to use the string constant
from a static constant variable, it does not correct the index for the
lower bound.  This causes us to get the wrong character for the "inlined"
array access.

Yes Store CCP should be doing this optimization instead of expand but
that is a different issue and is filed as PR 22303.

This patch fixes it by correcting the index that is used to retrieve
the character.

OK for the mainline? Bootstrapped and tested on x86_64-linux-gnu
and bootstrapped on powerpc-darwin (testing is in progress there).

Also is it okay for the 4.1 branch where this shows up too as a
regression in Fortran code because of the Fortran front-end
produces an array reference instead of an out-ofline function
which is what was produced in 4.0? Or do just reverting that 
the patch which exposed this latent bug is better idea for 4.1?

Thanks,
Andrew Pinski

ChangeLog:
	* expr.c (expand_expr_real_1) <case ARRAY_REF>:
	Use the corrected index for the character
	out of the string constant.

	* gfortran.dg/data_char_2.f90: New test.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixPR26001.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060131/a8dfc396/attachment.txt>


More information about the Gcc-patches mailing list