dereferencing null

Nathan M. Swan nathanmswan at gmail.com
Thu Mar 1 20:37:46 PST 2012


Am I correct that trying to use an Object null results in 
undefined behavior?

     Object o = null;
     o.opCmp(new Object); // segmentation fault on my OSX machine

This seems a bit non-D-ish to me, as other bugs like this throw 
Errors (e.g. RangeError).

It would be nice if it would throw a NullPointerError or 
something like that, because I spent a long time trying to find a 
bug that crashed the program before writeln-debugging statements 
could be flushed.

NMS


More information about the Digitalmars-d mailing list