Debug assertion failed

后端 未结 3 1082
孤城傲影
孤城傲影 2021-01-20 20:05

I keep encountering this \"Debug assertions failed!\" error when I run my program in debug mode. I tried looking this error up on the visual C++ website but the

相关标签:
3条回答
  • 2021-01-20 20:32

    Assertions are statements which only evaluate when you are running in debug mode (Cheap debug checking).

    For instance, this would fail assertion in debug, but would not cause an error in release:

    ASSERT(1 == 2);
    

    It's likely that some method you are calling expects a certain input and isn't getting it, but it doesn't cause an immediate error (So your code works in non-debug mode.)

    Hopefully that's helpful.

    If you can post your specific code, someone can probably help you with a more specific response.

    0 讨论(0)
  • 2021-01-20 20:44

    Asserts happen when program gets into illegal state. Assert is is written in code by programmer to notify him when something goes bad. You must start debugging from your IDE and press break when you get assert message. Than you should see what is condition in assert, like assert(i > 1024) and make sure that this never becomes true. Maybe you have some comment about meaning of assert, you must find line where it happens and why.

    0 讨论(0)
  • 2021-01-20 20:49

    Your code is corrupting the heap. The first snippet is from the C runtime library, the assert is telling you that your program is passing a bad pointer value to the delete operator.

    Commenting out the delete statements merely hides the problem. It will come back to haunt you a different way when you keep developing the program. There are some debugging tips in this thread. Learning how to catch these kind of bugs is a rite of passage for any C or C++ programmer. Welcome to the group.

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