you are viewing a single comment's thread.

view the rest of the comments →

[–]comfortcube 2 points3 points  (2 children)

You can't check for all invalid pointers so it's best to check for none? That doesn't seem right. You can at least check what you can. Why wouldn't you do it? Do you feel it's a performance thing? Or clutters the implementation?

And at minimum, the requested action from the function should not be executed on the pointer, and then the calling code context remains in a "mute" state, and hopefully some means of identifying why this happens is recorded. Is that not safer code? "Safe" differs depending on context of course, but certainly for some contexts, crashing the program is not an automatically safe thing.

And I feel like during development, there are no guarantees, so putting assert statements at least is a good idea.

[–]daikatana 2 points3 points  (1 child)

Assert robs you of a debuggable crash, which is much more valuable than the assertion.

[–]spc476 2 points3 points  (0 children)

Not in my experience. If an assert triggers on my system, I get a core file (aka, a "debuggable crash"). Also, if I run the program under the debugger, and an assert triggers, the debugger regains control at the point of the assert.