[Issue 6178] Struct inside the AA are not init correctly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 7 10:37:14 PDT 2013


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



--- Comment #20 from Kenji Hara <k.hara.pg at gmail.com> 2013-09-07 10:37:10 PDT ---
(In reply to comment #4)
> With an opAssign, an assignment to an AA struct will become something like
> 
>     Bug __aatmp1234 = void;   // <---
>     __aatmp1234.opAssign(1);
>     map.set(0, __aatmp1234);
>     map[0].___postblit();
> 
> the '3' is likely due to the '<---' line. See bug 2451.

This is the root cause. If the value struct in AA has opAssign method, it would
be called on uninitialized object.

For such structs, AA value setting should do additional work to distinguish
initializing and assignment.

struct S1 {
    void opAssign(S1 rhs) {}
}

S1[int] aa1;
aa1[1] = S1();  // [*]

I think the line at [*] should behave as follows:
1. If the key doesn't exist in aa yet, so it should work as initializing.
2. If the key already exists in aa, so it should work as assignment
   (== opAssign call).

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