How does D handle null pointers?
BCS
none at anon.com
Sat Aug 21 18:37:56 PDT 2010
Hello Adam,
>> Walter has refused to put in null checks on the theory that the OS
>> does it for you - hence the segfault. Of course, then the only way to
>> get a stacktrace is to either have a segfault handler which prints
>> one or to look at a core dump (assuming that you get one). Neither is
>> a very pleasant solution.
>>
> I see. I guess I can sympathize with Walter's perspective somewhat -
> it does feel redundant for both the application AND the OS to be
> checking pointers. Perhaps then it is the OS that's holding us back.
> If only we could trap a segfault signal and have the OS tell us which
> thread caused it and provide some mechanism to resume the thread with
> an exception... Hopefully some Linux kernel developers are reading
> this ;)
>
FWIW, throwing from inside a signal handler seems to work despite being undefined
and unsafe. YMMV, use at your own risk and don't plan on catching said exception
or counting anything to work.
--
... <IXOYE><
More information about the Digitalmars-d
mailing list