Serve Laurijssen said:
Well assert is not the way to gio then. You can add an assert like debug
facility that can be turned on/off by the user
The point, I think, is that an assert() that will be triggered *only*
if there's a bug in the code is acceptable, even in production code.
For example suppose you have a function that's intended only to accept
an argument value in the range 1..10. You might write it like this:
void func(int n)
{
assert(n >= 1 && n <= 10);
/* ... */
}
Assuming that func() is invoked by code in your application, that you
control, and never with some user-defined input value. Then a call
func(11) is a genuine bug in the program, not a data error.
If there's any combination of user data that can cause the assert() to
be triggered, then a different mechanism should be used, even if the
program just prints an error message and dies.
Now if you're able to recover from the error (perhaps by saving any
user data), that's even better, but your efforts as a developer are
probably better spent fixing the bug.