Thread overview
[Issue 2938] New: incorrect code generated for assignment to assoc array element
May 05, 2009
d-bugmail
Jan 14, 2010
David Simcha
Jun 14, 2010
Don
May 05, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2938

           Summary: incorrect code generated for assignment to assoc array
                    element
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: cristian@zerobugs.org


This code causes a range violation exception. It goes away if the postblit operator is commented away.

The root cause is in the front-end which generates code that gets the element at key zero (to create a temp as argument to opAssign). I was able to work around it in my back-end for .NET, but then the assertion fails, because the front-end does not generate the call to postblit.


struct X {
     int i;
     this(this) {
         ++i;
     }
}
void main() {
     X [int] xs;
     xs[0] = X();
     assert(xs[0].i == 1);
}


-- 

January 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2938


David Simcha <dsimcha@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha@yahoo.com


--- Comment #1 from David Simcha <dsimcha@yahoo.com> 2010-01-14 08:34:07 PST ---
Also happens when opAssign is overloaded:

struct Foo {
    uint stuff;

    void opAssign(Foo rhs) {
        stuff = rhs.stuff;
    }
}

void main() {
    Foo[string] AA;
    AA["bar"] = Foo.init;  // Range violation.
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=2938


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug@yahoo.com.au
         Resolution|                            |DUPLICATE


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-06-14 01:32:05 PDT ---
*** This issue has been marked as a duplicate of issue 2451 ***

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