[Issue 11204] New: Struct is destroyed before constructed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 9 02:59:15 PDT 2013


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

           Summary: Struct is destroyed before constructed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: samukha at voliacable.com


--- Comment #0 from Max Samukha <samukha at voliacable.com> 2013-10-09 02:59:12 PDT ---
This illustrates what I meant in bug 10186, comment 6:

struct S {
    @disable this(); 

    bool cted;
    this(int x) {
        cted = true;
    }

    static int destroyedBeforeConstructed;
    ~this() {
        if (!cted)
            destroyedBeforeConstructed++;
    }
}

class A {
    S s;

    this() {
        s = S(1);
    }
}

void main() {
    auto a = new A;
    assert(S.destroyedBeforeConstructed == 0);
}

Assertion fails because assignment triggers destruction of a struct that has
never been constructed.

With this one, object lifetime management remains fatally broken.

-- 
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