Need help locating AA bug

H. S. Teoh hsteoh at
Tue Feb 28 17:13:31 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.

Here's a short program that proves that something weird is going on:

	// TypeInfo test for getHash oddity.
	import std.stdio;

	void info(T)(T obj, string label) {
		writefln("Type of %s: %s", label, typeid(obj));
		writefln("Hash: %x", typeid(obj).getHash(&obj));

	void main() {
		int[] a1 = [1,2,3];
		const int[] a2 = [1,2,3];
		immutable int[] a3 = [1,2,3];

		info(a1, "a1");
		info(a2, "a2");
		info(a3, "a3");

Here's the output:

	Type of a1: int[]
	Hash: cdd7a389

	Type of a2: const(int)[]
	Hash: c3a051c9

	Type of a3: immutable(int)[]
	Hash: c3a051c9

Going to look into druntime now to find out what on earth is going on.


Talk is cheap. Whining is actually free. -- Lars Wirzenius

More information about the Digitalmars-d mailing list