Semantics of casting **to** shared?

dsimcha dsimcha at yahoo.com
Sat Sep 4 11:05:05 PDT 2010


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;
}


More information about the Digitalmars-d mailing list