Issue 12822 - Delegate .ptr assignment considered @safe
Summary: Delegate .ptr assignment considered @safe
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 critical
Assignee: No Owner
URL:
Keywords: accepts-invalid, pull, safe
Depends on:
Blocks:
 
Reported: 2014-05-30 12:40 UTC by David Nadlinger
Modified: 2016-10-01 11:47 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Nadlinger 2014-05-30 12:40:48 UTC
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.
Comment 1 Walter Bright 2016-06-08 04:33:48 UTC
https://github.com/dlang/dmd/pull/5851
Comment 2 github-bugzilla 2016-06-12 07:58:02 UTC
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
Comment 3 github-bugzilla 2016-06-13 20:29:33 UTC
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
Comment 4 github-bugzilla 2016-10-01 11:47:37 UTC
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