Visual C++ find line causing “Debug Assertion failed”

前端 未结 3 1773
野趣味
野趣味 2021-01-02 10:55

I am trying to get a C++ program that works fine when compiled with gcc to work properly on Visual C++. My problem is that I am now getting the following error:



        
相关标签:
3条回答
  • 2021-01-02 11:37

    You can open the call stack window (Debug->windows->CallStack) and find the spot in your program that led to the assertion. It should be 2 or 3 lines below the top line.

    0 讨论(0)
  • 2021-01-02 11:41

    I think the problem is that you are erasing members of the vector you are iterating through. What happens if you erase the first element?

    i 1 2 3 Ei v1 v2 v3

    If we erase 1 when i = 1, our vector indices and values are below and now i = 2.

    i 1 2 Ei v2 v3

    Ultimately, I think you can iterate past the end of the vector causing you to have a pointer that points past the end of the vector. Complete guess work here, but there is probably an easier way to do what you're trying to do. I just can't figure out what you're trying to do.

    It looks like you're trying to invert the rows and columns of a two dimensional array while storing the diagonal polygons int he array into a new array. Anyway, yes, but a red circle at the beginning of the for loop and walk through your code line by line.

    I would create temp vectors and then modify those ones in the for loop and then replace the vector openPolygonList.

    0 讨论(0)
  • 2021-01-02 11:41

    The debugger cannot predict the future, but you can tell it to break on all exceptions, (ctrl+atl+e and tick all the boxes under "Thrown"). When the assert happens walk down the call stack to your code it will tell you which line is causing the problem.

    0 讨论(0)
提交回复
热议问题