Disallow null references in safe code?

deadalnix deadalnix at gmail.com
Sat Feb 1 13:40:05 PST 2014


On Saturday, 1 February 2014 at 20:09:13 UTC, Andrei Alexandrescu 
wrote:
> This has been discussed to death a number of times. A field 
> access obj.field will use addressing with a constant offset. If 
> that offset is larger than the lowest address allowed to the 
> application, unsafety may occur.
>

That is one point. The other point is that the optimizer can 
remove a null check, and then a load, causing undefined behavior.

The solution to that is to prevent the optimizer from removing 
any load unless it can prove it has no side effect (cannot trap) 
which is certainly something we don't want to do (for manpower 
reason, we probably don't want to ditch exiting optimizers, as 
well as for the performance hit that this imply).


More information about the Digitalmars-d mailing list