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.
Confirmed, 3.4.0 accepted the code without an ICE even with checking enabled.
Subject: Bug 23337 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-08-16 22:07:45 Modified files: gcc : ChangeLog gimplify.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/ext: vector2.C Log message: ./ PR c++/23337 * gimplify.c (gimplify_init_ctor_eval): If we see an element of vector type, don't try to construct it element by element. Add an assertion that we use a FIELD_DECL when building a COMPONENT_REF. testsuite/ PR c++/23337 * g++.dg/ext/vector2.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9748&r2=2.9749 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&r1=2.145&r2=2.146 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5930&r2=1.5931 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vector2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 23337 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: ian@gcc.gnu.org 2005-08-16 22:17:10 Modified files: gcc : ChangeLog gimplify.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/ext: vector2.C Log message: ./ PR c++/23337 * gimplify.c (gimplify_init_ctor_eval): If we see an element of vector type, don't try to construct it element by element. Add an assertion that we use a FIELD_DECL when building a COMPONENT_REF. testsuite/ PR c++/23337 * g++.dg/ext/vector2.C: New. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.373&r2=2.7592.2.374 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimplify.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.113.2.10&r2=2.113.2.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.338&r2=1.5084.2.339 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/ext/vector2.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Now fixed on mainline and 4.0 branch.