Since logical && and || need to be evaluated component-wise for vectors, are c[0] and c[2] the only components that need to be evaluated because only b[0] and b[2] were nonzero? What if the RHS of && is a complicated expression(e.g. b&&foo())? Is the statement about evaluating the RHS only when LHS is equal/unequal to 0 meant only apply when both operands are scalar?
int4 a;
int4 b=(int4)(1,0,1,0);
int4 c=(int4)(10,10,10,10);
a=(b&&–c);
//a is (-1,0,-1,0) but should c be now (9,10,9,10) or (9,9,9,9)?
The 1.0 spec states:
“And (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0. Or (||) will only evaluate the right hand operand if the left hand operand compares equal to 0. For built-in vector types, the operators are applied component-wise”
The spec states that “And (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0.”. For the example above, c.x is evaluated only if b.x is not zero. Note that the left hand and right hand operands can be expressions. The expression will result in a scalar value. The statement in the spec is for evaluating the RHS only when LHS is equal/unequal to 0 for scalars.