Showing with 25 additions and 17 deletions.
  1. +1 −0 src/object_.d
  2. +12 −1 src/rt/aaA.d
  3. +12 −16 src/rt/typeinfo/ti_ptr.d
1 change: 1 addition & 0 deletions src/object_.d
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ class TypeInfo_Enum : TypeInfo_Typedef

}

// Please make sure to keep this in sync with TypeInfo_P (src/rt/typeinfo/ti_ptr.d)
class TypeInfo_Pointer : TypeInfo
{
override string toString() const { return m_next.toString() ~ "*"; }
Expand Down
13 changes: 12 additions & 1 deletion src/rt/aaA.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct Impl
size_t firstUsedBucketCache() @safe pure nothrow @nogc
in
{
assert(firstUsedBucket < buckets.length);
assert(firstUsedBucket <= buckets.length);
foreach(i; 0 .. firstUsedBucket)
assert(buckets[i] is null);
}
Expand Down Expand Up @@ -987,3 +987,14 @@ void _aaRangePopFront(ref Range r) pure nothrow @nogc
}
}
}

// Bugzilla 14104
unittest
{
import core.stdc.stdio;
alias K = const(ubyte)*;
size_t[K] aa;
immutable key = cast(K)(cast(size_t)uint.max + 1);
aa[key] = 12;
assert(key in aa);
}
28 changes: 12 additions & 16 deletions src/rt/typeinfo/ti_ptr.d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*/
module rt.typeinfo.ti_ptr;

// pointer
// internal typeinfo for any pointer type
// please keep in sync with TypeInfo_Pointer

class TypeInfo_P : TypeInfo
{
Expand All @@ -24,22 +25,22 @@ class TypeInfo_P : TypeInfo

override size_t getHash(in void* p)
{
return cast(uint)*cast(void* *)p;
return cast(size_t)*cast(void**)p;
}

override bool equals(in void* p1, in void* p2)
{
return *cast(void* *)p1 == *cast(void* *)p2;
return *cast(void**)p1 == *cast(void**)p2;
}

override int compare(in void* p1, in void* p2)
{
auto c = *cast(void* *)p1 - *cast(void* *)p2;
if (c < 0)
if (*cast(void**)p1 < *cast(void**)p2)
return -1;
else if (c > 0)
else if (*cast(void**)p1 > *cast(void**)p2)
return 1;
return 0;
else
return 0;
}

override @property size_t tsize() nothrow pure
Expand All @@ -49,15 +50,10 @@ class TypeInfo_P : TypeInfo

override void swap(void *p1, void *p2)
{
void* t;

t = *cast(void* *)p1;
*cast(void* *)p1 = *cast(void* *)p2;
*cast(void* *)p2 = t;
void* tmp = *cast(void**)p1;
*cast(void**)p1 = *cast(void**)p2;
*cast(void**)p2 = tmp;
}

override @property uint flags() nothrow pure
{
return 1;
}
override @property uint flags() nothrow pure const { return 1; }
}