"Vector Subscript Out of Range" even with item in container...

Hello,

I will try my best to describe this problem I am having because I am not sure if I can reproduce the error in a small code example as this is part of a large code project.

I have a plain std::vector which contains pointers to objects.

When attempting to delete the objects, even if I know for a fact that the std::vector has at least one object in it as shown by the debugger, I get the "Vector Subscript Out of Range" error.

I'll even do a range for loop like so:

1
2
3
4
5
for (auto & e : CurrentObjects) {
		
	delete e;

}


And yet I still get the "Vector Subscript Out of Range" error. The destructor is never called for the object represented by "e" so I am not sure why I get the error.

Any ideas why that might be the case?

Thank you for your time.
What stack trace tells you?

And it should be impossible to get that error with range-based loops as they do not use subscript at all. Are you sure that this is the fragment which contains error?
I have been troubleshooting this for a while; maybe you're right in that I am looking in the wrong place.

Because it is a large project I am not sure exactly where I am calling something outside of range of a vector I am using.
Have you tried debugging from the crash and stepping up the call stack to find which line in your code is crashing?
I think I found the issue; it has to do with something completely different and I will create a separate thread for it.

Thank you for your help.
Topic archived. No new replies allowed.