DMD 2.065 (same for current Git master, 4fbe9f4) accepts the following, obviously unsafe code: --- class C { int a; int func() { return a; } } @safe void test() { auto c = new C(); auto dg = &c.func; dg.ptr = new long; dg(); } --- .ptr/.funcptr cannot be assigned safely, as the type system does not model the context pointer type.
https://github.com/dlang/dmd/pull/5851
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/51143be746a36c43bc6c25f85648b13dc57e5585 fix Issue 12822 - Delegate .ptr assignment considered @safe https://github.com/dlang/dmd/commit/0f2c901890e04699bf5a151a992b5eecf8d0cfde Merge pull request #5851 from WalterBright/fix12822 fix Issue 12822 - Delegate .ptr assignment considered @safe
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/73301fec8727569aedd6f9f94a2217a38a525d24 Actually test compiler output for issue 12822 This is a fix-up for pull #5851. https://github.com/dlang/dmd/commit/f7d88d54d8f499ed05a9ecd3b28c819c8ecdf8bb Merge pull request #5865 from denis-sh/patch-2 Actually test compiler output for issue 12822
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/51143be746a36c43bc6c25f85648b13dc57e5585 fix Issue 12822 - Delegate .ptr assignment considered @safe https://github.com/dlang/dmd/commit/0f2c901890e04699bf5a151a992b5eecf8d0cfde Merge pull request #5851 from WalterBright/fix12822 https://github.com/dlang/dmd/commit/73301fec8727569aedd6f9f94a2217a38a525d24 Actually test compiler output for issue 12822 https://github.com/dlang/dmd/commit/f7d88d54d8f499ed05a9ecd3b28c819c8ecdf8bb Merge pull request #5865 from denis-sh/patch-2