This C++ program:
typedef int vec __attribute__ ((vector_size (8)));
extern int bar (vec);
int
foo (int i)
{
vec a[] = { (vec) { 0, i }, (vec) { 4, 5 } };
return bar (a[0]) + bar (a[1]);
}
when compiled with or without optimization gives this ICE in a compiler with
checking enabled:
/home/ian/foo.cc: In function int foo(int):
/home/ian/foo.cc:6: internal compiler error: tree check: expected field_decl,
have integer_cst in component_ref_field_offset, at expr.c:5683
The misstep which leads to that is in gimplify_init_ctor_eval which assumes that
if array_elt_type is NULL that purpose is a FIELD_DECL. That is not true when
constructing a vector type. However, the problem presumably has to be fixed at
a higher level, since as far as I know there is no equivalent to ARRAY_REF or
COMPONENT_REF for vector types.
The same program does not ICE in C, so I'm reporting this as a C++ bug. Perhaps
C++ is generating incorrect GENERIC. Or perhaps the fact that C uses
COMPOUND_LITERAL_EXPR makes it work more or less by accident in C.
--
Summary: ICE initializing array of vectors in C++
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23337