Nilium #1 Because the vector is not allocated in the heap, it's in the stack. So you're returning a pointer to something that, once out of the stack frame, is freed. You can probably guess what's wrong with that.