[Issue 11952] struct field initialization with postblit causes un-needed destruction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 19 12:58:05 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11952


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal


--- Comment #1 from monarchdodra at gmail.com 2014-01-19 12:58:04 PST ---
(In reply to comment #0)
> http://forum.dlang.org/thread/xfmqyplfxmdmrnotdzil@forum.dlang.org

Actually, I'm bumping to bug. Here is a variant of the code in the thread:

//----
import std.stdio;

struct B
{
    A sup;

    this(A a)
    {
        writeln("Here");
        sup = a;
        writeln("There");
    }
}

struct A
{
    static int count;

    this() @disable; //Note this

    this(int n)
    {
        writeln("A.this()");
    }

    this(this)
    {
        writeln("A.this(this)");
    }

    ~this()
    {
        writeln("A.~this()");
    }
}

void main()
{
    A a = A(1);

    writeln("Start");
    B b = B(a);
    writeln("End");
}
//----
A.this()
Start
A.this(this)
Here
A.this(this)
A.~this() //WHAT???
There
A.~this()
End
A.~this()
A.~this()
//----

Here, "A" has a disabled default init. Yet in B's constructor, "A.~this()" is
clearly called on a default initialized instance, which should *never* (AFAIK)
happen unless previously and explicitly initialized to A.init (not the case
here).

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


More information about the Digitalmars-d-bugs mailing list