Assertion failure comparing STL strings

On Windows using Visual C++ Express 2008, I have code that used two strings such as:

std::string left;
std::string right;

and after they have been assigned values it will call something like:

std::equal(left.begin(), left.end(), right.begin(), CaselessCompare());

CaselessCompare is a functor class that will compare the string character by character to determine how they match up.

When this code execute a macro named _SCL_SECURE_VALIDATE_RANGE causes an assertion failure in a module called xstring:

1
2
3
4
5
6
7
8
9
10
11
12
13
	_Myt& __CLR_OR_THIS_CALL operator+=(difference_type _Off)
		{	// increment by integer
		if (this->_Mycont != _IGNORE_MYCONT)
		{
			_SCL_SECURE_VALIDATE(this->_Has_container());
			_SCL_SECURE_VALIDATE_RANGE(
				_Myptr + _Off <= (((_Mystring *)this->_Mycont)->_Myptr() + ((_Mystring *)this->_Mycont)->_Mysize) &&
				_Myptr + _Off >= ((_Mystring *)this->_Mycont)->_Myptr());
		}
		_Myptr += _Off;
		return (*this);
		}
The code looks perfectly fine and legitimate. There does not seem to be any reason why an assertion failure should occur.

What can be done to prevent the assertion failure from happening?
What does CaselessCompare look like?
Topic archived. No new replies allowed.