|
|
|
|
|
by pilif
5580 days ago
|
|
I assume he was proving a point where main() of his full program using error code checking was not in fact checking the return value of foo() Even in simple example code like this you can forget a check. In this case that result would be undefined if any call to devide failed. I'd much rather have my program blow up with a readable stack trace pointing to where it happened than it working with a basically random value and then maybe blowing up somewhere totally unrelated or worse, destroying user data. |
|
You don't need exceptions to get a callstack and you can assert that values are valid and force a crash / callstack dump when they're not.
On top of that, you can compile the asserts out for release builds if you're confident they won't be hit.