Better diagnostics for null classes dereferencing

Steven Schveighoffer schveiguy at yahoo.com
Tue Jul 10 22:07:52 UTC 2018


On 7/10/18 5:18 PM, kdevel wrote:
> On Tuesday, 10 July 2018 at 21:09:23 UTC, Steven Schveighoffer wrote:
> [...]
>> As far as the OS is concerned, a[2 .. $] is within the process memory 
>> limit.
>>
>> Of course, that's an out of bounds access, so the compiler or the 
>> bounds check *should* complain.
> 
> It complains at runtime
> 
>     > ./dumpme2
>     core.exception.RangeError at dumpme2.d(4): Range violation
>     ----------------
>     ??:? _d_arrayboundsp [0x42bb1e]
>     dumpme2.d:4 _Dmain [0x42ba42]
> 
> but how do I force the runtime to generate a coredump for real 
> post-mortem analysis?

More difficult. You'd have to have a special runtime, and change the 
constructor for RangeError to access a null pointer.

-Steve


More information about the Digitalmars-d-learn mailing list