[Issue 6581] Yet another dtor/postblit problem?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 1 13:58:40 PDT 2011


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



--- Comment #2 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2011-09-01 13:58:35 PDT ---
It might be more complicated then I thought, postblits of members do work.
I'd better leave the cause of problem to thouse in the know. Another variation
of test:

import std.stdio;

struct A
{
    static int ctor, post, dtor;

    this(int dummy){ ctor++; }
    this(this){ post++; }
    ~this(){ dtor++; }
}

struct B
{
    A a;
    static int ctor, post, dtor;
    this(int dummy){ 
        a = A(dummy); // a(dummy) was a typo, thought it changes nothing
        ctor++; 
    }
    this(this){ post++; }
    ~this(){ dtor++; }
}


void main()
{
    {
        B b = B(42);
        auto c = b;
    }
        // all works as long as it's "shallow"
    assert(B.post == 1);
    assert(B.ctor == 1);
    assert(B.dtor == 2);

    writefln("%s %s %s", A.ctor, A.post, A.dtor);//prints 1 1 3
    assert(A.ctor == 1);
    assert(A.post == 1);
    assert(A.dtor == 2);//fails
}

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