Semantics of casting **to** shared?
Jason House
jason.james.house at gmail.com
Sat Sep 4 11:59:10 PDT 2010
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;
> }
More information about the Digitalmars-d
mailing list