Bug 6254 – Problem with associative array with array of array as keys
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-07-05T10:43:00Z
Last change time
2013-11-07T07:42:47Z
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2011-07-05T10:43:33Z
This program:
static immutable(char[][]) toConstMatrix(char[][] M) {
immutable(char[])[] result;
foreach (row; M)
result ~= row.idup;
return result;
}
void main() {
char[][] M = [" ".dup, " ".dup, " ".dup, " ".dup, " ".dup];
auto a = toConstMatrix(M);
auto b = toConstMatrix(M);
bool[char[][]] foo;
foo[a] = true;
assert(a == b, "a != b");
assert(a in foo, "a not in foo");
assert(b in foo, "b not in foo");
}
DMD 2.053 gives:
[email protected](15): b not in foo
But I think the hash of a dynamic array of a dynamic array has to be computed on just the contents (and lengths) of the arrays.
Comment #1 by verylonglogin.reg — 2013-11-07T07:42:47Z
I'll mark this (earlier) report as duplicate as later one contains more info.
*** This issue has been marked as a duplicate of issue 10380 ***