www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13536] New: Union of delegates breaks safety

https://issues.dlang.org/show_bug.cgi?id=13536

          Issue ID: 13536
           Summary: Union of delegates breaks  safety
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

------
struct S {
        void sysMethod()  system {}
}
void fun()  safe {
        union U {
                void delegate()  system sysDg;
                void delegate()  safe safeDg;
        }
        U u;
        S s;
        u.sysDg = &s.sysMethod;
        // s.sysMethod(); // the compiler catches this
        u.safeDg(); // but not this
}
------

--
Sep 26 2014