import std.stdio;
void main()
{
int[uint] aa;
aa[1236448822] = 0;
aa[2716102924] = 1;
aa[ 315901071] = 2;
aa.remove(1236448822);
writefln(aa[2716102924]);
}
========================
The reason it happens is in aaA.d:
int c = key_hash - e.hash;
//...
if (c < 0) {
e = e.left;
} else {
e = e.right;
}
If key_hash is bigger than e.hash + int.max, this will incorrectly determine that it is in fact smaller. The loop should be changed to something like
while (e) {
if (key_hash == e.hash) {
int c = keyti.compare(pkey, e + 1);
if (c) {
e = c < 0 ? e.left : e.right;
} else {
return cast(void *)(e + 1) + keysize;
}
} else {
e = key_hash < e.hash ? e.left : e.right;
}
}
Comment #1 by thomas-dloop — 2006-12-06T08:30:39Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] schrieb am 2006-12-05:
> http://d.puremagic.com/issues/show_bug.cgi?id=653
> import std.stdio;
>
> void main()
> {
> int[uint] aa;
>
> aa[1236448822] = 0;
> aa[2716102924] = 1;
> aa[ 315901071] = 2;
>
> aa.remove(1236448822);
> writefln(aa[2716102924]);
> }
>
>========================
>
> The reason it happens is in aaA.d:
<snip>
Added to DStress as
http://dstress.kuehne.cn/run/a/associative_array_20_A.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFdrJSLK5blCcjpWoRAjQdAKCS9JQ83XzP4+sZauiiWoSh+AJLwACfdicv
KCf6KvzSB+CXziDxqTaloJg=
=4Zse
-----END PGP SIGNATURE-----