Casting scalars to vectors

Anton,

Clang was generating an error on vector initializers, when all the vector slots are not provided, i.e.:

vector unsigned int v = (vector unsigned int)(vector int)(-1);

Instead of:

vector unsigned int v = (vector unsigned int)(vector int)(-1, -1, -1, -1);

I’m seeing these kinds of statements in some headers in the PS3 sdk, which gcc allows.

I’ve checked in a fix and revised the altivec tests. (Sorry I missed a test last night, and broke the build.)

I have a question, though (for Anton or anyone). What will the initializers be for the unspecified slots? Will they be 0? What does gcc do?

-John

I’ve run into a problem with vector literal/casting confusion:

vector float v = (vector float)((vector unsigned int)(0x49800000));

vecinit1.cpp:1:33: error: cannot initialize a vector element of type ‘float’ with an lvalue of type ‘__vector unsigned int’
vector float v = (vector float)((vector unsigned int)(0x49800000));

It appears to be treating the outer paren expression as a vector literal instead of a cast.

I’m looking into to it, but if someone knows a quick fix already…

-John