Better diagnostics for null classes dereferencing

Steven Schveighoffer schveiguy at yahoo.com
Tue Jul 10 21:09:23 UTC 2018


On 7/10/18 5:01 PM, kdevel wrote:
> On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote:
>> On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote:
> [...]
>> Run the program in a debugger, or run `ulimit -c unlimited` to enable 
>> core dumps [...]
> 
> Works for null ptr deref but how do I enforce core dumps in this code:
> 
> dumpme2.d
> ---
> void main ()
> {
>     int [1] a;
>     auto s = a[2 .. $];
> }
> ---
> 

Core dumps are triggered from the process accessing memory it doesn't 
own. 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.

-Steve


More information about the Digitalmars-d-learn mailing list