I am trying to get C ++ - a program that works great when compiling with gcc to work correctly in Visual C ++. My problem is that now I get the following error:
Debug Assertion Failed! Program: C:\WINDOWS\SYSTEM32\MSVCP110D.dll File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\vector Line: 1140 Expression: vector subscript out of range
My real problem is that I do not know when and where this happens. By clicking a break in the error window, I simply relate to the part of the vector class where the exception ultimately occurred. I want to find a place in my application that actually caused it. I managed to narrow it down to this code block:
for(unsigned int i=0;i<openPolygonList.size();i++)//error somewhere in here { if (openPolygonList[i].size() < 1) continue; for(unsigned int j=0;j<openPolygonList.size();j++) { if (openPolygonList[j].size() < 1) continue; Point diff = openPolygonList[i][openPolygonList[i].size()-1] - openPolygonList[j][0]; int64_t distSquared = vSize2(diff); if (distSquared < 2 * 2) { if (i == j) { polygonList.push_back(openPolygonList[i]); openPolygonList.erase(openPolygonList.begin() + i); }else{ for(unsigned int n=0; n<openPolygonList[j].size(); n++) openPolygonList[i].push_back(openPolygonList[j][n]); openPolygonList[j].clear(); } } } }
Simply placing drag points in each row where the vector is used is not an option, because the cycle repeats thousands of times and clicking the Continue button will literally take me for hours every time. Is there a way to tell the debugger about a stop on the corresponding line after an error occurs, so that I can check the variables and determine which one is out of range?
source share