--- gcc/testsuite/gcc.dg/20041227-1.c.jj 2004-12-27 13:57:19.126504511 +0100 +++ gcc/testsuite/gcc.dg/20041227-1.c 2004-12-27 13:57:15.864087556 +0100 @@ -0,0 +1,5 @@ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-mmmx" } */ + +typedef short int V __attribute__ ((vector_size (8))); +static V v = (V) 0x00FF00FF00FF00FFLL;
gives ICE in both GCC 3.4.3-RH and on HEAD. Depending whether checking is enabled or not, it either results in checking failure in digest_init or in a segfault in build_vector. The problematic hunk is (c-typeck.c (digest_init)): /* Build a VECTOR_CST from a *constant* vector constructor. If the vector constructor is not constant (e.g. {1,2,3,foo()}) then punt below and handle as a constructor. */ if (code == VECTOR_TYPE && TREE_CODE (TREE_TYPE (inside_init)) == VECTOR_TYPE && vector_types_convertible_p (TREE_TYPE (inside_init), type) && TREE_CONSTANT (inside_init)) { if (TREE_CODE (inside_init) == VECTOR_CST && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (inside_init)), TYPE_MAIN_VARIANT (type))) return inside_init; else return build_vector (type, CONSTRUCTOR_ELTS (inside_init)); } Changing it to else if (TREE_CODE (inside_init) == CONSTRUCTOR) return build_vector (type, CONSTRUCTOR_ELTS (inside_init)); else return inside_init; fixes this, but I have trouble to understand what the code really wants to do. If inside_init is a VECTOR_CST, then if comptypes returns 0, this results in a checking failure too, as a VECTOR_CST is not a CONSTRUCTOR and CONSTRUCTOR_ELTS is solely for CONSTRUCTORs. So, either the inner test should be only if (TREE_CODE (inside_init) == CONSTRUCTOR) return build_vector ...; else return inside_init; with no checking for VECTOR_CST etc., or there needs to be different actions for VECTOR_CST that are compatible, for those where comptypes on TREE_TYPE (inside_init) and type gives non-zero, but for their main variants gives zero (is that even possible?), for CONSTRUCTORS and for other trees that can end up in that place (the testcase here has there a NOP_EXPR with INTEGER_CST inside). -- Summary: ICE in digest_init or build_vector Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,rth at redhat dot com GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19164