[Issue 18592] New: Associative array assignment with a destructor should be @safe if the destructor is @safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 11 20:27:47 UTC 2018


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

          Issue ID: 18592
           Summary: Associative array assignment with a destructor should
                    be @safe if the destructor is @safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: greensunny12 at gmail.com

cat > main.d << EOF
void main() @safe
{
    struct ThrowingElement
    {
        int i;
        ~this()
        {
            assert(1);
        }
    }

    ThrowingElement[int] aa;
    aa[0] = ThrowingElement(0);
}
EOF


The problem is that the generated opAssign is @system:

ref return @system ThrowingElement opAssign(ThrowingElement p)
{
        (ThrowingElement __swap2 = void;) , __swap2 = this , this = p ,
__swap2.~this();
        return this;
}

--


More information about the Digitalmars-d-bugs mailing list