No, you're fine with this code. The garbage collector only moves managed (ref class) objects allocated on the GC heap. It doesn't mess with the stack or the JIT compiled code.
You don't have to worry about inducing bugs like this, the compiler always warns you about it. Try making the vector a member of the class for example. Now it would be a problem, the GC does move an object of type "test".
Hans Passant
2010-10-21 15:55:49