AA struct hashing bug?

Alex Parrill via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 7 14:03:42 PST 2015


On Monday, 7 December 2015 at 18:48:18 UTC, Random D user wrote:
> struct Foo
> {
>     this( int k )
>     {
>         a = k;
>     }
>     int a;
> }
>
> Foo foo;
> int[ Foo ] map;
>
> map[ foo ] = 1;  // Crash! bug?
>
> // This also crashes. I believe crash above makes a call like 
> this (or similar) in the rt.
> //auto h = typeid( foo ).getHash( &foo ); // Crash!
>
> win64 & dmd 2.69.2

Also works on DMD v2.069.2 on XUbuntu Linux x64. I can try it on 
Windows later.

Exact code I tested:

struct Foo
{
     this( int k )
     {
         a = k;
     }
     int a;
}

void main() {
	Foo foo;
	int[ Foo ] map;

	map[ foo ] = 1;
}



More information about the Digitalmars-d-learn mailing list