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]

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


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.

Attachment: fixPR26001.diff.txt
Description: ASCII C program text


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