[Issue 24820] Associative arrays do not correctly handle keys with copy constructors
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 18 10:05:52 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24820
--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
FYI, opAssign should have been
```
void opAssign()(auto ref S rhs)
{
writefln("Assigning %s, count(%s) to %s, count(%s)",
rhs.i, rhs.count, this.i, this.count);
if(this.count)
{
++this.count.assignedTo;
--this.count.refCount;
}
if(rhs.count)
{
++rhs.count.assignedFrom;
++rhs.count.refCount;
}
this.count = rhs.count;
this.i = rhs.i;
}
```
I screwed it up and mutated this.count instead of rhs.count in the rhs.count
section, but it doesn't actually get triggered with what main is doing, so it
doesn't really matter. The example has more than is strictly necessary to show
the bug, because I was trying to show exactly what was going on without knowing
for sure which operations the AA would be using.
--
More information about the Digitalmars-d-bugs
mailing list