G
Guest
Hi,
I'm trying to "port" a project from VC++ 2003 to VC++ 2005 (Express
Edition). This project contains the following code on several places (It is
not exactly this code but a generalization of what it does.):
vector<int> int_vector;
vector<int>::iterator i, j;
for (i = int_vector.begin (); i != int_vector.end (); i++)
{
for (j = int_vector.begin (); j != int_vector.end (); j++)
{
if ((*j) == (*i))
{
int_vector.erase (j);
}
}
}
I realize the reason for doing this is not obvious in the generalization
above but a bit more understandable in the actual context (although far from
"good code" I assume).
The result of this is that an assert fails with the following information:
File: c:\program files\microsoft visual studio 8\vc\include\vector
Line: 117
Expression: ("this->_Mycont != NULL", 0)
This is one of the ++-operators in vector and the assert occurs on the
"i++"-instruction in the code above. _SCL_SECURE_VALIDATE (this->_Mycont !=
NULL) seems to be the assert that fails.
I have read about "Debug iterator support" and "Checked iterators" here:
http://msdn2.microsoft.com/en-us/library/ms235424(VS.80).aspx. It seems to me
that the assert has to do with one of these. I also read that these can be
disabled by using the following:
#define _HAS_ITERATOR_DEBUGGING 0
#define _SECURE_SCL 0
I have put these the first thing in the cpp-file with my main-function. I
still seem to get the assert failure. My questions are:
1) What, exactly, is causing the assert failure?
2) Is it possible to revert to the VC++ 2003 behavior where there is no
failure?
3) Is my theory about "Debug iterator support" and "Checked iterators" a
dead end or am I just using the #DEFINE:s the wrong way?
I want to point out that I realize that the obvious solution is to rewrite
the offending parts of the code. However, I have not written the code in
question myself so at this point I do not want to do this. I just want to
recreate the behavior from VC++ 2003 to recreate a functioning program and
then take it from there.
I'm trying to "port" a project from VC++ 2003 to VC++ 2005 (Express
Edition). This project contains the following code on several places (It is
not exactly this code but a generalization of what it does.):
vector<int> int_vector;
vector<int>::iterator i, j;
for (i = int_vector.begin (); i != int_vector.end (); i++)
{
for (j = int_vector.begin (); j != int_vector.end (); j++)
{
if ((*j) == (*i))
{
int_vector.erase (j);
}
}
}
I realize the reason for doing this is not obvious in the generalization
above but a bit more understandable in the actual context (although far from
"good code" I assume).
The result of this is that an assert fails with the following information:
File: c:\program files\microsoft visual studio 8\vc\include\vector
Line: 117
Expression: ("this->_Mycont != NULL", 0)
This is one of the ++-operators in vector and the assert occurs on the
"i++"-instruction in the code above. _SCL_SECURE_VALIDATE (this->_Mycont !=
NULL) seems to be the assert that fails.
I have read about "Debug iterator support" and "Checked iterators" here:
http://msdn2.microsoft.com/en-us/library/ms235424(VS.80).aspx. It seems to me
that the assert has to do with one of these. I also read that these can be
disabled by using the following:
#define _HAS_ITERATOR_DEBUGGING 0
#define _SECURE_SCL 0
I have put these the first thing in the cpp-file with my main-function. I
still seem to get the assert failure. My questions are:
1) What, exactly, is causing the assert failure?
2) Is it possible to revert to the VC++ 2003 behavior where there is no
failure?
3) Is my theory about "Debug iterator support" and "Checked iterators" a
dead end or am I just using the #DEFINE:s the wrong way?
I want to point out that I realize that the obvious solution is to rewrite
the offending parts of the code. However, I have not written the code in
question myself so at this point I do not want to do this. I just want to
recreate the behavior from VC++ 2003 to recreate a functioning program and
then take it from there.