Debugging question

dekeenfrance (64)
Hello,

I am writing a program of scientific simulation on Visual Studio. In my simulation there is a big vector of pointers who point to a big number of objects each one consists of some vectors.

When I run the simulation, sometimes it works normally, sometimes it throw an exception by citing "Vector iterator out of range" or "vector iterator not dereferencable".

The code is very long so I cannot put it here. I just put a fraction of the debug file called "vector" automatically made by Visual Studio. Because I don't know what it means and how I can find my error through this.

Could someone knows this please tell me how to debug this error? Thanks in advance.

1
2
3
4
5
6
7
8
9
10
	_Myiter& operator+=(difference_type _Off)
		{	// increment by integer
 #if _ITERATOR_DEBUG_LEVEL == 2
		if (this->_Getcont() == 0
			|| this->_Ptr + _Off < ((_Myvec *)this->_Getcont())->_Myfirst
			|| ((_Myvec *)this->_Getcont())->_Mylast < this->_Ptr + _Off)
			{	// report error
			_DEBUG_ERROR("vector iterator + offset out of range");
			_SCL_SECURE_OUT_OF_RANGE;
			}
cire (2345)
The error is a logic error in your code, not that of std::vector.
dekeenfrance (64)
Could you please explain a bit more?
toum (203)
The code you're showing us is the part of code of std::vector that displays an error if ever the call to the iterator's operator+=() causes the iterator to be out of range.

You need to find the part of your code that tried to increment an iterator just before the error occured.
Registered users can post here. Sign in or register to post.