Ok - continue digging into the scenario - i have found that the project contains /analyze switch which forces the Code Analysis option of VS2012 to always run.
when removing this switch, the above (nasty i agree) code compiles without any warning.
now, as this specific code compiles with no warning on VS2010 64 bit environment, then VS2010 vs. VS2012 code analysis rules differences are the primary suspect for the warning.
currently, i've passed this roadblock in my migration efforts, i'll try to continue understand the rules thing differences later on. if someone can shade some light on it it would be great to post it here.
EDIT: i have found out that Code Analyzer is not working on VS2010 - the compiler switch is ignored, which explains why this code is compiling. Anyhow a proper re-factor is required.
EDIT 2
Folks, after intensive thinking (almost 6 months) i finally found the root cause...
m_pValueChecks = new set<string>*[oOther.m_vData.size()];
for(size_t i = 0; i < oOther.m_vData.size(); ++i)
{
if(NULL == oOther.m_pValueChecks[i])
{
m_pValueChecks[i] = NULL;
}
else
{
/// commpiler warns on the below line
m_pValueChecks[i] = new set<string>(oOther.m_pValueChecks[i]->begin(), oOther.m_pValueChecks[i]->end());
}
}
The reasons is because the for
loop increments the i
index using ++i
, which means first the i
variable is incremented, then being used.
This means there might be a chance the i
variable will be more than oOther.m_vData.size()
which is the size of the m_pValueChecks
allocated array.
Changing the for
floop to for(size_t i = 0; i < oOther.m_vData.size(); i++)
removed the warning.