On Monday, February 03, 2014 22:23:51 Meta wrote: > On Monday, 3 February 2014 at 22:18:35 UTC, Jonathan M Davis > > wrote: > > For it to know, it would have to examine the body of foo (which > > it doesn't > > necessarily have the code for under C's compilation model - > > which D uses), and > > even if it did that wouldn't be enough e.g. > > > > int* foo() > > { > > > > return "/etc/foo".exists ? new int : null; > > > > } > > > > The compiler could flag that as _possibly_ returning null and > > therefore the > > previous code _possibly_ dereferencing null, but it can't know > > for sure. > > If null is an invalid value to assign to a pointer, then there's > no issue.
Yes, but I wasn't talking about non-nullable pointers. I was talking about how in the general case, it's impossible to determine at compile time whether a nullable pointer is null and that it's therefore impossible (in the general case) to determine at compile time whether dereferencing a nullable pointer will attempt to dereference null. Non-nullable pointers side-steps the issue entirely. - Jonathan M Davis