@safe - why does this compile?

Piotr Mitana the.mail.of.mi2 at gmail.com
Fri Jul 13 11:04:40 UTC 2018


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.


More information about the Digitalmars-d-learn mailing list