[Issue 19830] New: core.memory.__delete destructs arrays of structs in the wrong order

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 26 14:09:07 UTC 2019


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

          Issue ID: 19830
           Summary: core.memory.__delete destructs arrays of structs in
                    the wrong order
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: slavo5150 at yahoo.com

int sdtor8;

struct S8
{   int b = 7;
    int c;
    ~this()
    {
        printf("~S8() %d\n", sdtor8);
        assert(b == 7);
        assert(sdtor8 == c);
        sdtor8++;
    }
}

void test8()
{
    S8[] s = new S8[3];
    s[0].c = 2;
    s[1].c = 1;
    s[2].c = 0;
    delete s;
    assert(sdtor8 == 3);
}

assertion failure at `assert(sdtor8 == c)` due to __delete destructing in the
order 0,1,2 instead of the order 2,1,0.

--


More information about the Digitalmars-d-bugs mailing list