Shouldn't invalid references like this fail at compile time?

Seb seb at wilzba.ch
Tue Jan 23 01:04:58 UTC 2018


On Tuesday, 23 January 2018 at 00:20:45 UTC, Mike Franklin wrote:
> On Monday, 22 January 2018 at 23:30:16 UTC, Aedt wrote:
>> [...]
>
> D is not memory safe by default (unfortunately), so it's not 
> surprising to me that you can do this in `@system` code.  I 
> would be surprised if the compiler allowed you to do something 
> like this in `@safe` code.  To make your programs memory safe, 
> you should add `@safe` to your `main` function.
>
> Mike

Yep, DMD will complain:

https://run.dlang.io/is/x0Xfx8


More information about the Digitalmars-d mailing list