I noticed I get a "Vector Iterators Incompatible" error when I try to compare two different copies of a vector.
There are enough questions about this error to find how to solve it:
Why am I getting “vector iterators incompatible”?
C++ STL vector iterators incompatible
Debug Assertion : Vector iterators incompatible (C++)
Vector Iterators Incompatible
My question is: is it possible to either disable the check in debug or enable the check in release to make both configurations behave the same way?
My question is NOT: What the error means, what causes it, or how to resolve it.
Additional Details
My compiler options, in debug mode, are:
/ZI /nologo /W3 /WX- /Od /Oy- /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Debug\test.pch" /Fa"Debug\" /Fo"Debug\" /Fd"Debug\vc100.pdb" /Gd /analyze- /errorReport:queue
And, in release mode:
/Zi /nologo /W3 /WX- /O2 /Oi /Oy- /GL /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm- /EHsc /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Yu"StdAfx.h" /Fp"Release\test.pch" /Fa"Release\" /Fo"Release\" /Fd"Release\vc100.pdb" /Gd /analyze- /errorReport:queue
Here is a little snippet of code to reproduce the error:
#include <vector>
#include <iostream>
#include <string>
using namespace std;
class foo{
public:
const std::vector<int> getVec(){return myVec;} //other stuff omitted
private:
std::vector<int> myVec;
};
int main(int argc, char* argv[])
{
foo myFoo = foo();
std::vector<int>::const_iterator i = myFoo.getVec().begin();
while( i != myFoo.getVec().end())
{
//do stuff
++i;
}
string s;
cin >> s;
return 0;
}