http://d.puremagic.com/issues/show_bug.cgi?id=2483


Denis <verylonglogin....@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin....@gmail.com
            Version|1.037                       |D1 & D2


--- Comment #1 from Denis <verylonglogin....@gmail.com> 2012-01-22 17:10:28 MSK 
---
This bug leads to not calling destructor for the stack object and deleting the
last heap object instead:
---
import std.stdio;

scope class C {
    int n;
    this(int n) { writefln(" this(%s) at %s", this.n = n, cast(void*)this); }
    ~this() { writefln("~this(%s) at %s", n, cast(void*)this); }
}

void main() {
    int i;
    writefln("Stack is at %s", &i);
    writefln("Heap  is at %s", (new void[1]).ptr);
    {
        scope C c = new C(1); // at stack, never destroyed
        c = new C(2); // at heap, destroyed on collect
        c = new C(3); // ditto
        c = new C(4); // at heap, destroyed on scope exit
    }
    writeln("after scope");
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to