Null pointer dereferencing in D

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 13 14:23:00 PDT 2014


This indeed has been already discussed. Long story short :

Making dereferencing null a defined behavior is extremely
expensive from the optimizer perspective. That mean that every
single load can have side effect, so the optimizer can't optimize
them away unless it can prove that the pointer is not null. It
also cannot reorder load anymore unless it can prove they are not
null.

This mean 2 things:
   - D programs will be much slower
   - We won't be able to reuse existing optimizers out of the box.

That sound like a terrible idea to me. And ultimately, it won't
solve the problem of null pointers that can all over the place
(this is major issue in some codebases).

The approach consisting in having non nullable pointers/reference
by default is the one that is gaining traction and for good
reasons.


More information about the Digitalmars-d mailing list