[Issue 9334] New: Dtor and postblit for struct heap object are not always called

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 17 08:22:22 PST 2013


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

           Summary: Dtor and postblit for struct heap object are not
                    always called
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: maxim at maxim-fomin.ru


--- Comment #0 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-01-17 08:22:18 PST ---
If struct object allocated on heap is default constructed, dtor is not called.
If one has non-default initializer, dtor (and postblit) is called.

import std.stdio : writefln;

struct S
{
    int i;
    this(this) { writefln("%X postbit", i); i = 0;}
    ~this() { writefln("%X dtor", i); }
}

auto foo()
{
    S* s = new S(); // add any argument to new to call dtor
}

void main()
{
    foo();
}

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


More information about the Digitalmars-d-bugs mailing list