@safe - why does this compile?
    bauss 
    jj_1337 at live.dk
       
    Fri Jul 13 12:55:18 UTC 2018
    
    
  
On Friday, 13 July 2018 at 11:04:40 UTC, Piotr Mitana wrote:
> This code:
>
>     import std.stdio;
>
>     class X1 {}
>     class X2 : X1
>     {
> 	void run() @safe
>         {
>             writeln("DONE");
>         }
>     }
>
>     void main() @safe
>     {
>         X1 x1 = new X1;
>         X2 x2 = cast(X2) x1;
>         x2.run();
>     }
>
> is obviously wrong gets killed by OS's signal. Why is it @safe? 
> I thought @safe should prevent such errors as well.
See: https://dlang.org/spec/function.html#function-safety
    
    
More information about the Digitalmars-d-learn
mailing list