www.digitalmars.com         C & C++   DMDScript  

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


          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


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 2017