www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12822] New: Delegate .ptr assignment considered safe


          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 puremagic.com
          Reporter: code 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;

.ptr/.funcptr cannot be assigned safely, as the type system does not model the
context pointer type.

May 30 2014