Hello,
I have a feeling the website is wrong. If you went to
http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html, it claims
"In C vectors can be subscripted as if the vector were an array with the
same number of elements and base type. Out of bound accesses invoke
undefined behavior at runtime. Warnings for out of bound accesses for
vector subscription can be enabled with -Warray-bounds. "
I went through the gcc source code and the extend.texi does not have
this statement anymore. Why is that not reflected on the website?
When i tried that in a simple example.
#define vector __attribute__((vector_size(16) ))
static inline vector int vectadd(vector int t1, vector int t2)
{
return t1 + t2;
}
vector int a = {0, 1, 0, 1, 0, 0, 0, 0};
vector int b = {0, 0, 1, 1, 0, 0, 0, 0};
vector int c = {0, 1, 1, 0, 0, 0, 0, 0};
int main(void)
{
vector int a0;
a0 = vectadd(a, b);
if (a0[2] != 1)
__builtin_abort ();
return 0;
}
I get a compiler error "error: subscripted value is neither array nor
pointer".
Cheers
Hari