digitalmars.D.bugs - [Issue 653] New: AAs are slightly broken
- d-bugmail puremagic.com (46/46) Dec 05 2006 http://d.puremagic.com/issues/show_bug.cgi?id=653
- Thomas Kuehne (12/25) Dec 06 2006 -----BEGIN PGP SIGNED MESSAGE-----
- d-bugmail puremagic.com (9/9) Dec 12 2006 http://d.puremagic.com/issues/show_bug.cgi?id=653
http://d.puremagic.com/issues/show_bug.cgi?id=653
Summary: AAs are slightly broken
Product: D
Version: 0.176
Platform: PC
OS/Version: Windows
Status: NEW
Severity: major
Priority: P1
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: mslenc gmail.com
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;
}
}
--
Dec 05 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-12-05:http://d.puremagic.com/issues/show_bug.cgi?id=653import 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-----
Dec 06 2006
http://d.puremagic.com/issues/show_bug.cgi?id=653
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed DMD 0.176
--
Dec 12 2006









Thomas Kuehne <thomas-dloop kuehne.cn> 