[PATCH] Fix PR35043, ICE with asking for unsigned_type_for (bitsizetype)

Richard Guenther rguenther@suse.de
Mon Feb 4 13:28:00 GMT 2008


This fixes mentioned PR by making sure to not produce ARRAY_REFs with
bitsizetype index type during gimplification, but instead use the base
type of the array domain.  The defect that unsigned_type_for returns
NULL for bitsizetype will be fixed in 4.4.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to mainline.

Richard.

2008-01-31  Richard Guenther  <rguenther@suse.de>

	PR middle-end/35043
	* gimplify.c (gimplify_init_ctor_eval): Convert array indices
	to TYPE_DOMAINs base type instead of using bitsizetype here.

	* gcc.c-torture/compile/pr35043.c: New testcase.

Index: testsuite/gcc.c-torture/compile/pr35043.c
===================================================================
*** testsuite/gcc.c-torture/compile/pr35043.c	(revision 0)
--- testsuite/gcc.c-torture/compile/pr35043.c	(revision 0)
***************
*** 0 ****
--- 1,20 ----
+ typedef long unsigned int size_t;
+ typedef struct   {
+       long double dat[2];
+ } gsl_complex_long_double;
+ typedef struct {
+     size_t size;
+     size_t stride;
+     long double *data;
+ } gsl_vector_complex_long_double;
+ void gsl_vector_complex_long_double_set_zero (gsl_vector_complex_long_double * v) 
+ {
+     long double * const data = v->data;
+     const size_t n = v->size;
+     const size_t stride = v->stride;
+     const gsl_complex_long_double zero = { { 0.0L,0.0L} } ;
+     size_t i;
+     for (i = 0; i < n; i++)     
+         *(gsl_complex_long_double *) (data + 2 * i * stride) = zero;
+ }
+ 
Index: gimplify.c
===================================================================
*** gimplify.c	(revision 132090)
--- gimplify.c	(working copy)
*************** gimplify_init_ctor_eval (tree object, VE
*** 3096,3101 ****
--- 3096,3105 ----
  
        if (array_elt_type)
  	{
+ 	  /* Do not use bitsizetype for ARRAY_REF indices.  */
+ 	  if (TYPE_DOMAIN (TREE_TYPE (object)))
+ 	    purpose = fold_convert (TREE_TYPE (TYPE_DOMAIN (TREE_TYPE (object))),
+ 				    purpose);
  	  cref = build4 (ARRAY_REF, array_elt_type, unshare_expr (object),
  			 purpose, NULL_TREE, NULL_TREE);
  	}



More information about the Gcc-patches mailing list