Don wrote:
With the bugs I've fixed in the DMD source, I've seen very many cases of
7, several cases of 2 and 6, and only one case of 8.
Many bugs are also caused by dangerous casts (where a pointer is cast
from one type to another).
But almost everything else been caused by a logic error.
I am certain that there are still many null pointer bugs in DMD.
None of the null pointer bugs dmd has had would have been prevented by using
non-nullable types. I.e. they were not "I forgot to initialize this pointer",
but were instead the result of logic errors, like running off the end of a list.
NULL in dmd represents "this datum has not been computed yet" or "this datum has
an invalid value" or "this datum does not exist". With non-nullable types,
they'd have to be set to a datum that asserts whenever it is accessed, leading
to the same behavior.
Having the program abort due to an assert failure rather than a segment
violation is not the great advance it's sold as. I think one should carefully
consider whether a particular null pointer problem is a symptom of a logic bug
or not before claiming that eliminating null pointers will magically resolve it.
Otherwise, you're just shooting the messenger.