www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11952] New: struct field initialization with postblit causes un-needed destruction

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11952

           Summary: struct field initialization with postblit causes
                    un-needed destruction
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: monarchdodra gmail.com



Given a struct "B" with a field "sup" of type "A", where "A" has a postblit.
Then intialization "sup" triggers a postblit (good), but also destroys the
prior value of "sup" (useless).

Just the way we can avoid "assign" on first initialization, postblit
destruction should be avoided as well.

From learn:
http://forum.dlang.org/thread/xfmqyplfxmdmrnotdzil forum.dlang.org

In the thread, the user see a wrong amount of reference counts because of this
issue.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 19 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11952


monarchdodra gmail.com changed:

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




 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: -------
Jan 19 2014