null dereference exception vs. segfault?

bearophile bearophileHUGS at lycos.com
Mon Aug 2 14:27:22 PDT 2010


Ryan W Sims:
> The problem isn't how to check it on a case-by-case basis, there are 
> plenty of ways to check that a given pointer is non-null. The problem is 
> debugging _unexpected_ null dereferences, for which a NPE or its 
> equivalent is very helpful, a segfault is _not_.

I don't know what NPE is, but if you program with DbC your nulls are very often found out by asserts, so you have assert errors (that show line number & file name) instead of segfaults.


> Sorry, didn't mean to reopen a can of worms, just wanted to be clear.

When people that discuss are polite there is no problem in reopening the can now and then :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list