On Monday, 28 March 2016 at 21:01:19 UTC, cy wrote:
I finally found the null pointer. It took a week. I was
assigning "db = db" when I should have been assigning "this.db
= db". Terrible, I know. But...
I invoked db.find_chapter.bindAll(8,4), when db was a null
pointer. There was no null pointer error. No exception raised
for dereferencing a null. I'm not in release mode. Assertions
are enabled. Shouldn't that have raised a null pointer
exception?
Instead, it accesses db as if db were not null, producing a
garbage structure in find_chapter, which bindAll chokes on,
then causes the whole program to segfault.
I realize enforce(db).find_chapter would work, but... I thought
D was more careful about null pointers? At least enough to die
on dereferencing them?
You can use a lint to warn you about silly mistakes, check out
dscanner and possibly others.