debug assertion failed

  • Thread starter Thread starter Daniel
  • Start date Start date
Daniel said:
What does it mean when I get an error that says "Debug Assertion Failed" ?

It means there is a bug in your code. Break the program and look at what the
assertion is about. Usually the assertion will be in code you did not write
yourself. Follow the call stack back until you reach your own code.
 
A debug assertion is code that is only present at debug. It tests an assumed
precondition and halts program execution immediately to bring attention to
the fact that the code is being executed while in a state never intended by
the author.

For example:

void Harvest(string vegetable)
{
ASSERT(vegetable != "cow")

// do work with vegetable
}

In this case it is possible to pass in a non vegetable, but the author is
assuming that no one would ever do this. In order to not waste time in a
release build checking every possible input the author beleives it is better
to ferret out impropper use of the routine at debug time. This way the
behavior will be immediately identified and corrected before the software
goes to release and clock cycles will not be wasted testing for a case that
will never happen.
 
Back
Top