hack on @safe functions
Pavel
phondogo at gmail.com
Mon Feb 3 22:08:58 PST 2014
Some suggesting to compiler checking for that case.
If talking about Linux OS it reserves first page (4kb on 32bit
cpu, 8kb on 64) for null fault case (try to dereference pointer
in that memory addresses will cause segmentation fault or smth
like this).
So compiler can check (at compile time) each structure field
access for dereference with ofset > OS page size add code for
check pointer of structure for null. Or when trying to get
pointer of field that is in the range of page size, but field
type size + ofset of this field > page size.
In this solution there will be very little overhead cause it is
very rare case that structures have size > page size.
Sorry for my bad english. :)
More information about the Digitalmars-d
mailing list