safeD doesn't mean your code is safe... only "memory safe". Similarly, "shared" 
sort of partitions data and there is no provably safe way to create or use it. 
I have no idea if your example is truly legit safeD or not...

dsimcha Wrote:

> I noticed that the following code compiles even in SafeD.  Is this a bug?  If
> not, what are the semantics of casting unshared to shared?  TDPL doesn't seem
> to mention this.  Isn't it dangerous to have shared and unshared references to
> the same memory?
> 
> @safe:
> class Foo {
>     uint num;
> }
> 
> void main() {
>     auto foo = new Foo;
>     auto bar = cast(shared) foo;
> }

Reply via email to