From a66bf90b88dfd5587d6f020d5bf4225f2784190a Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Fri, 1 Jun 2018 09:57:58 -0400 Subject: [PATCH] Fix Issue 18932 - core.internal.hash.hashOf(val, seed) ignores `seed` when val is a raw pointer --- src/core/internal/hash.d | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/internal/hash.d b/src/core/internal/hash.d index a480d81ed9..7288ad46d1 100644 --- a/src/core/internal/hash.d +++ b/src/core/internal/hash.d @@ -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 @@ -107,7 +107,7 @@ 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 { @@ -115,7 +115,7 @@ if (!is(T == enum) && is(T V : V*) && !is(T : typeof(null)) } } - return hashOf(cast(size_t)val); + return hashOf(cast(size_t)val, seed); } //struct or union hash @@ -394,6 +394,8 @@ unittest assert(h28 == rth28); assert(h29 == rth29);*/ assert(h30 == rth30); + + assert(hashOf(null, 0) != hashOf(null, 123456789)); // issue 18932 }