[Issue 17867] New: @trusted destructor not callable from @safe function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 30 17:18:20 UTC 2017


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 at puremagic.com
          Reporter: andrei at 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.

--


More information about the Digitalmars-d-bugs mailing list