www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17867] New: trusted destructor not callable from safe

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

          Issue ID: 17867
           Summary:  trusted destructor not callable from  safe function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

Consider:

struct S
{
     system ~this() {}
}

struct T
{
    S member;
     trusted ~this() {}
}

 safe void main()
{
    T obj;
}

This code should work because although the member's destructor is  system, the
object containing it makes it safe. The code fails with:

Error:  safe function 'D main' cannot call  system destructor 'test.T.~this'

Couldn't find a convenient workaround.

--
Sep 30