local memory + operator[]

Hi!

Is this normal that such a structure

struct Vector3

{

    float x,y,z;

    __device__ inline float& operator[](const unsigned int i)

    {

        switch(i)

        {

             case 0: return x;

             case 1: return y;

             default: return z;

        }

    }

};

forces all vector3 to be allocated in local memory, but

if i define a function that has exacly the same code, but is used like vector.at(i) then vectors stay in registers / shared memory.

Is that normal? and why? :)

edit: sorry, wrong board.

I’ve used operator and didn’t get my stuff placed in lmem. Do this: try -maxrregcount=128 and try to play around with keywords (remove inline, don’t use const, don’t use a switch, use a class, etc.)