Assertion is used to check whether a condition is met(precondition, postcondition, invariants) and help programmers find holes during debugging phase.
For example,
void f(int *p)
{
assert(p);
p->do();
}
My question is do we need to assume the condition could not be met in release mode and handle the case accordingly?
void f(int *p)
{
assert(p);
if (p)
{
p->do();
}
}
After all, assertion means that the condition it tests should NEVER be false. But if, if we don't check it and it fails, program crashes. Sounds like a dilemma. How do you guys deal with it?