Let's suppose we have this code:
uint4 var;
instructions....
if(var == 0)
.....
compiler gives me this error:
error: expression must have arithmetic or pointer type
if(var == 0)
Nothing changes if I do an explicit cast, (uint4), over 0 or I use (0,0,0,0) instead of 0.
I think this is not correct, because section 6.3.e of OpenCL specs says that the "==" operator should work also on vector types and if the operand types doesn't match, an implicit conversion will be done on one of the operands.
Same problem applies for "!=" operator.
Its not the operator, but the usage of if condition which is causing the problem here.
As the error message says, if condition requires the arguments to be arithmetic, enum, or pointer type.
You can use any() or all() function, if the resultant conditional expression is a vector.
Originally posted by: omkaranathan Its not the operator, but the usage of if condition which is causing the problem here.
As the error message says, if condition requires the arguments to be arithmetic, enum, or pointer type.
You can use any() or all() function, if the resultant conditional expression is a vector.
Uhm, I don't think this point is clear to me: why if I use an int/uint variable it's all ok, but if I use a vector type then it's not? Shouldn't be both "arithmetic types"?
And if not, then how I can test if a vectorized variable has all components equal to zero? any() and all() doesn't give me this information...
if you use == operator with uint4 data type you get four bool result and you mus specify logical operator between them.
Uhm, I don't think this point is clear to me: why if I use an int/uint variable it's all ok, but if I use a vector type then it's not? Shouldn't be both "arithmetic types"?
And if not, then how I can test if a vectorized variable has all components equal to zero? any() and all() doesn't give me this information...
Write something like-
if(all(var==(uint4)(0)))