www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5234] New: [qtd] AA element assignment should use copy-constructor to initialize new elements

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

           Summary: [qtd] AA element assignment should use
                    copy-constructor to initialize new elements
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: samukha voliacable.com


--- Comment #0 from Max Samukha <samukha voliacable.com> 2010-11-18 08:23:00
PST ---
Currently opAssign is called on newly created AA elements of struct types. This
leaves us absolutely no possibility to properly initialize AA elements without
introducing costly and unreliable checks in opAssign:

struct QString
{
    ref QString opAssign(ref QString other)
    {
        if (memcmp(cast(void*)&this, cast(void*)&T.init, sizeof(this)) == 0)
        {
            // construct copy
        }
        else
        {
            // assign
        }
    }
}

QString[int] ss;
QString s = qs("some string");
ss[0] = s;

Can AA be modified so that new elements are initialized with the
copy-constructor (as they should be) and not opAssign?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5234



--- Comment #1 from Max Samukha <samukha voliacable.com> 2010-11-18 08:37:19
PST ---
T.init should be QString.init in the example

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5234


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-09-07 10:05:51 PDT ---
*** This issue has been marked as a duplicate of issue 6178 ***

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