folly: ubsan: HashTest: avoid invalid shift (sanitize=shift)
authorLucian Grijincu <lucian@fb.com>
Mon, 1 Feb 2016 19:45:53 +0000 (11:45 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Mon, 1 Feb 2016 20:20:26 +0000 (12:20 -0800)
Summary:
  [ RUN      ] Hash.TWang_Unmix64
  folly/test/HashTest.cpp:125:20: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int'

Reviewed By: philippv

Differential Revision: D2886144

fb-gh-sync-id: 8d7963c087c9db34b08c07451d35e5568c750520

folly/test/HashTest.cpp

index de12b1e02ae2b58ef55a12145803882efb58101d..94993dddde0f4d36abbe5b594747610c1235b194 100644 (file)
@@ -122,9 +122,9 @@ void checkTWang(uint64_t r) {
 TEST(Hash, TWang_Unmix64) {
   // We'll try (1 << i), (1 << i) + 1, (1 << i) - 1
   for (int i = 1; i < 64; i++) {
-    checkTWang((1U << i) - 1);
-    checkTWang(1U << i);
-    checkTWang((1U << i) + 1);
+    checkTWang((uint64_t(1) << i) - 1);
+    checkTWang(uint64_t(1) << i);
+    checkTWang((uint64_t(1) << i) + 1);
   }
 }