[RFC] Throwing an exception with null pointers

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Mon Apr 14 15:33:02 UTC 2025


On 14/04/2025 10:01 PM, a11e99z wrote:
> On Monday, 14 April 2025 at 09:49:27 UTC, a11e99z wrote:
>> On Saturday, 12 April 2025 at 23:11:41 UTC, Richard (Rikki) Andrew 
>> Cattermole wrote:
>>> I've been looking once again at having an exception being thrown on 
>>> null pointer dereferencing.
>>
>> null pointer in x86 is any pointer less than 0x00010000
>>
>> imo need to dig into .net source and grab their option
> 
> almost same problem is misaligned access:
> x86/x64 allows this except few instructions
> ARM - prohibit it (as I know)

The only way for this to occur in @safe code is program corruption.

> it seems there are no other options except to handle kernel signals and 
> WinSEH

They are both geared towards killing the process, from what I've read 
its really not a good idea to throw an exception using them. Even if we 
could rely upon the signal handler being what we think it is.

We do not support the MSVC exception mechanism for Windows 64bit of dmd, 
so even if we wanted to do this, we cannot.



More information about the Digitalmars-d mailing list