From 66a84355ab8a6c2b1e724e844ef4a79ca22a5cf7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 29 May 2023 17:17:15 -0600 Subject: [PATCH] [hash] Use unsigned types Hopefully ubsan wouldn't complain about overflows now. --- src/hb-algs.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-algs.hh b/src/hb-algs.hh index 8caf76cac..44fe24841 100644 --- a/src/hb-algs.hh +++ b/src/hb-algs.hh @@ -321,10 +321,10 @@ struct // https://github.com/harfbuzz/harfbuzz/pull/4228#issuecomment-1565079537 template ::value && sizeof (T) <= sizeof (uint32_t))> constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 2654435761 /* Knuh's multiplicative hash */) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, v * 2654435761u /* Knuh's multiplicative hash */) template ::value && sizeof (T) > sizeof (uint32_t))> constexpr auto - impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (v ^ (v >> 32)) * 2654435761 /* Knuth's multiplicative hash */) + impl (const T& v, hb_priority<1>) const HB_RETURN (uint32_t, (v ^ (v >> 32)) * 2654435761u /* Knuth's multiplicative hash */) template constexpr auto impl (const T& v, hb_priority<0>) const HB_RETURN (uint32_t, std::hash>{} (hb_deref (v)))