hack on @safe functions

Pavel phondogo at gmail.com
Mon Feb 3 22:11:29 PST 2014


On Tuesday, 4 February 2014 at 06:08:59 UTC, Pavel wrote:
> 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. :)

In that case there will be no need for dissallowing null pointers 
in safe code.


More information about the Digitalmars-d mailing list