I am using GNU compiler under redhat enterprise linux 9.0.
First of all I didn't use resize in my last part of the code, I used SIZE to show that if I use  after using reserve() procedure SIZE will not notice that there is some elements in the array. And that is because reserve() is thought to delacre that some memory is going to be used but reserve() does not fill the array for you, you should do it using push_back() method. Because int, double, etc are build-in type using  actually will work but size(), at() and I guess iterators will not realize about the change, so you will not be able to use size() and iterators in your loop later on. That is the inconsistency. On the other hand, if you use resize() that will allocate the memory and fill the array for you with default numbers of the type you are using (int, double, etc). So, finally, the safest way to do is use resize() in all the loops, as follows:
for(int i = 0; i < length; i++)
So, Same as you, I had troubles using reserve an directly accessing using . That was I told in my previous post to the other user that gave some comments. But he told me that in his compiler is working well.