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

Commit

Permalink
Merge pull request #2202 from n8sh/core-hash-18932
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dlang-bot committed Jun 3, 2018
2 parents 907f591 + a66bf90 commit 52f2367
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/internal/hash.d
Expand Up @@ -94,7 +94,7 @@ size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && __traits
@trusted nothrow pure
size_t hashOf(T)(auto ref T val, size_t seed = 0) if (!is(T == enum) && is(T : typeof(null)))
{
return hashOf(cast(void*)null);
return hashOf(cast(void*)null, seed);
}

//Pointers hash. CTFE unsupported if not null
Expand All @@ -107,15 +107,15 @@ if (!is(T == enum) && is(T V : V*) && !is(T : typeof(null))
{
if(val is null)
{
return hashOf(cast(size_t)0);
return hashOf(cast(size_t)0, seed);
}
else
{
assert(0, "Unable to calculate hash of non-null pointer at compile time");
}

}
return hashOf(cast(size_t)val);
return hashOf(cast(size_t)val, seed);
}

//struct or union hash
Expand Down Expand Up @@ -394,6 +394,8 @@ unittest
assert(h28 == rth28);
assert(h29 == rth29);*/
assert(h30 == rth30);

assert(hashOf(null, 0) != hashOf(null, 123456789)); // issue 18932
}


Expand Down

0 comments on commit 52f2367

Please sign in to comment.