[libcxx-commits] [PATCH] D134124: [libc++] Fix wrong implementation of CityHash
Tommy Chiang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Sep 18 00:12:49 PDT 2022
oToToT created this revision.
oToToT added reviewers: EricWF, ldionne.
Herald added a project: All.
oToToT requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.
As PR56606 stated, the current implementation of CityHash in libc++
would drop some bits unintentionally. Cast the 32bit int to the 64bit
int to avoid this happened.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134124
Files:
libcxx/include/__functional/hash.h
Index: libcxx/include/__functional/hash.h
===================================================================
--- libcxx/include/__functional/hash.h
+++ libcxx/include/__functional/hash.h
@@ -135,7 +135,7 @@
if (__len >= 4) {
const uint32_t __a = __loadword<uint32_t>(__s);
const uint32_t __b = __loadword<uint32_t>(__s + __len - 4);
- return __hash_len_16(__len + (__a << 3), __b);
+ return __hash_len_16(__len + (static_cast<_Size>(__a) << 3), __b);
}
if (__len > 0) {
const unsigned char __a = static_cast<unsigned char>(__s[0]);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134124.461049.patch
Type: text/x-patch
Size: 579 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220918/598abd82/attachment.bin>
More information about the libcxx-commits
mailing list