Need help locating AA bug

H. S. Teoh hsteoh at
Tue Feb 28 18:11:41 PST 2012

On Tue, Feb 28, 2012 at 12:04:45PM -0800, Walter Bright wrote:
> On 2/28/2012 7:20 AM, H. S. Teoh wrote:
> >That's strange, because I'm clearly seeing a difference in hash
> >value.  Calling map1's keyti.getHash(key) yields a different value
> >from map2's keyti.getHash(key).
> The thing to do then is look at those two getHash functions, and see
> how they are computing it.

Question: how does the compiler generate TypeInfo objects for
const(int)[] and immutable(int)[]?

I think that's where the bug lies. I wrote a program to manually call
rt.util.hash.hashOf by casting const and immutable int arrays' ptr into
void* and passing in the data directly (this is what
typeid(int[]).getHash() does), and the hash values are consistent with

However, calling typeid(const(int)[]).getHash and
typeid(immutable(int)[]).getHash produces a different value (the same
between const and immutable, but different from unqualified int[]). So
it looks like const and immutable int[] are using some kind of generic
array typeinfo code? But I have trouble finding where in the druntime
code this is.

In any case, the generic array typeinfo code is obviously doing
something different from the hand-coded typeid(int[]), that's why the
hash value is inconsistent.


Маленькие детки - маленькие бедки.

More information about the Digitalmars-d mailing list