[Issue 12822] New: Delegate .ptr assignment considered @safe

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri May 30 05:40:48 PDT 2014


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: nobody at puremagic.com
          Reporter: code at klickverbot.at

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.

--


More information about the Digitalmars-d-bugs mailing list