From: Ivan Maidanski Date: Wed, 21 Aug 2019 08:31:52 +0000 (+0300) Subject: Fix subexpression widening in memhash() of disclaim_weakmap_test X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=508292feccc04648da687e1fdadecbba908fba4e;p=gc Fix subexpression widening in memhash() of disclaim_weakmap_test (fix of commit 0cc2c0e7e) It would be more correct to widen the argument (from unsigned to GC_word) of multiply operation instead of implicit widening of the result. * tests/disclaim_weakmap_test.c (memhash): Cast acc to GC_word before multiplying by 2003; cast the whole expression to unsigned type (before assigning it to acc). --- diff --git a/tests/disclaim_weakmap_test.c b/tests/disclaim_weakmap_test.c index cb6d0500..516a3fd7 100644 --- a/tests/disclaim_weakmap_test.c +++ b/tests/disclaim_weakmap_test.c @@ -98,7 +98,7 @@ unsigned memhash(void *src, size_t len) my_assert(len % sizeof(GC_word) == 0); for (i = 0; i < len / sizeof(GC_word); ++i) { - acc = (2003 * acc + ((GC_word *)src)[i]) / 3; + acc = (unsigned)((2003 * (GC_word)acc + ((GC_word *)src)[i]) / 3); } return acc; }