[Issue 14126] GITHEAD - GC seemingly corrupting memory

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Feb 6 00:43:13 PST 2015


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

--- Comment #9 from sinkuupump at gmail.com ---
Looks like the destructor is called with wrong 'this' pointer.


import core.stdc.stdio;

struct Foo {
    private uint _foo = 1;

    ~this() {
        printf("%p\n", &this);
    }
}

void main() {
    Foo[] foos;
    foos.length = 512;
    foreach (ref f; foos) printf("%p\n", &f);
    printf("--------------\n");
}


Output:
0x7fa2a6420010
0x7fa2a6420014
0x7fa2a6420018
...
--------------
...
0x7fa2a6420019
0x7fa2a6420015
0x7fa2a6420011

--


More information about the Digitalmars-d-bugs mailing list