I have come across what I consider weird behaviour with the c++11 range-based for loop when assigning to elements of a dynamically allocated std::vector. I hav
std::vector
The reason your loop fails is because you reference vector elements by value. However, in this case you can eliminate the loop altogether:
dataInput.read(reinterpret_cast(CTdata->data()), arraySize*sizeof(short int));
This reads the content into the vector in a single call.