Question

I'm using following stupid code:

std::vector<wxString> m_redoSteps;
...
m_redoSteps.clear();

When I'm compiling with Visual Studio 6 or GCC m_redoSteps.clear() works fine, when I use visual Studio 2010 there is an assertion "vector iterators incompatible" (which leads to a crash in release build).

Any ideas what is wrong here?

--

Edit: Adding one more line of code:

std::vector<wxString> m_redoSteps;
...
if (!m_redoSteps.empty())
{
   // do something in case it is not empty - which isn't in my case
   ...
}
m_redoSteps.clear(); // first call leads to the assertion...
Was it helpful?

Solution

Install visual studio 2010 sp1, see this bug report : http://connect.microsoft.com/VisualStudio/feedback/details/545013

Update (April 14, 2015):

The bug description is 545013: The "vector::erase" constraint returns an incompatible iterator in the debug build.

The original link http://connect.microsoft.com/VisualStudio/feedback/details/545013 is not available, however a cache of the original bug is here http://web.archive.org/web/20140727031651/http://connect.microsoft.com/VisualStudio/feedback/details/545013

The bug was resolved in Visual Studio SP 1 as described here Description of Visual Studio 2010 Service Pack 1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top