https://issues.dlang.org/show_bug.cgi?id=12822
Issue ID: 12822
Summary: Delegate .ptr assignment considered @safe
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
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.
--