Patch for PR21969 (large vector causes ICE)

Steve Ellcey sje@cup.hp.com
Mon Jun 20 16:55:00 GMT 2005


While looking at some vector issues I found that creating a vector with
256 or more elements would create an ICE because the number of elements
is stored in a 9 bit integer field and large values would get truncated.
This change is to give a sensible error message instead of an ICE.

Tested on IA64 Linux and HP-UX.  OK for checkin?


Steve Ellcey
sje@cup.hp.com

2005-06-20  Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/21969
	* c-common.c (handle_vector_size_attribute):  Check for large
	vectors.


testsuite ChangeLog:


2005-06-20  Steve Ellcey  <sje@cup.hp.com>

	PR middle-end/21969
	* gcc.dg/vect/pr21969.c: New test.


*** gcc.orig/gcc/c-common.c	Mon Jun 20 09:43:34 2005
--- gcc/gcc/c-common.c	Mon Jun 20 09:43:24 2005
*************** handle_vector_size_attribute (tree *node
*** 4983,4988 ****
--- 4983,4996 ----
        return NULL_TREE;
      }
  
+   /* nunits is stored in precision field which is "unsigned int : 9",
+      256 is the largest value that can be stored.  */
+   if (nunits > 256)
+     {
+       error ("number of components of the vector greater than 256");
+       return NULL_TREE;
+     }
+ 
    new_type = build_vector_type (type, nunits);
  
    /* Build back pointers if needed.  */
*** gcc.orig/gcc/testsuite/gcc.dg/vect/pr21969.c	Mon Jun 20 09:44:36 2005
--- gcc/gcc/testsuite/gcc.dg/vect/pr21969.c	Mon Jun 20 09:42:44 2005
***************
*** 0 ****
--- 1,4 ----
+ /* { dg-do compile } */
+ /* { dg-require-effective-target vect_float } */
+ 
+ typedef float vsf __attribute__((vector_size(2048))); /* { dg-error "number of components of the vector greater than 256" } */



More information about the Gcc-patches mailing list