Hi,
there is something I don’t understand, this code compiles:
struct X {
float x,y,w;
float &operator[](const int &i) {
return x;
}
};
__device__ void s() {
X x;
x.x = 3.0f;
float h = 3.0f;
x[1] = h;
}
this doesn’t
struct X {
float x,y,w;
float &operator[](const int &i) {
switch(i) {
case 0:
return x;
}
return x;
}
};
__device__ void s() {
X x;
x.x = 3.0f;
float h = 3.0f;
x[1] = h;
}
compilation fails with:
error: operand of "*" must be a pointer
Why does nvcc behave in this way?