Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 52f2367

Browse files
authored
Merge pull request #2202 from n8sh/core-hash-18932
Fix Issue 18932 - core.internal.hash.hashOf(val, seed) ignores `seed` when val is a raw pointer merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents 907f591 + a66bf90 commit 52f2367

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/internal/hash.d

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits
9494
@trusted nothrow pure
9595
size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T : typeof(null)))
9696
{
97-
return hashOf(cast(void*)null);
97+
return hashOf(cast(void*)null, seed);
9898
}
9999

100100
//Pointers hash. CTFE unsupported if not null
@@ -107,15 +107,15 @@ if (!is(T == enum) && is(T V : V*) && !is(T : typeof(null))
107107
{
108108
if(val is null)
109109
{
110-
return hashOf(cast(size_t)0);
110+
return hashOf(cast(size_t)0, seed);
111111
}
112112
else
113113
{
114114
assert(0, "Unable to calculate hash of non-null pointer at compile time");
115115
}
116116

117117
}
118-
return hashOf(cast(size_t)val);
118+
return hashOf(cast(size_t)val, seed);
119119
}
120120

121121
//struct or union hash
@@ -394,6 +394,8 @@ unittest
394394
assert(h28 == rth28);
395395
assert(h29 == rth29);*/
396396
assert(h30 == rth30);
397+
398+
assert(hashOf(null, 0) != hashOf(null, 123456789)); // issue 18932
397399
}
398400

399401

0 commit comments

Comments
 (0)