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, middle-end] Fix PR 37861 - Bogus array bounds warning


Hi,

the following patch gets rid of the bogus warning.

The problem is, that fwprop currently generates array_refs of the form
&(*formatstr_3(D))[cumulative_offset] for  multidimensional arrays and
the cumulative offset can then naturally be bigger than the respective
dimension of the array.  

This  happens because, when  multidimensional arrays  are passed  as a
formal   parameter,  they   are  gimplified   into  a   pointer,  thus
formatstr[10][100] becomes  char[100] * formatstr.  We do  not want to
be doing the  transformation on such variables and  the patch inhibits
them.

I have bootstrapped and regression tested it on x86_64-suse-linux
(revision 141561).  I hope this won't cause any performance problems.

OK for trunk?

Martin

2008-11-05  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/37861
	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Don't turn
	pointer arithmetics into array_ref if the array is accessed
	through an indirect_ref.

 
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c	(revision 141546)
+++ gcc/tree-ssa-forwprop.c	(working copy)
@@ -812,6 +812,7 @@ forward_propagate_addr_expr_1 (tree name
   array_ref = TREE_OPERAND (def_rhs, 0);
   if (TREE_CODE (array_ref) != ARRAY_REF
       || TREE_CODE (TREE_TYPE (TREE_OPERAND (array_ref, 0))) != ARRAY_TYPE
+      || TREE_CODE (TREE_OPERAND (array_ref, 0)) == INDIRECT_REF
       || !integer_zerop (TREE_OPERAND (array_ref, 1)))
     return false;
 


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