Work around a false positive in MSVC debug runtime checker
In some MSVC versions on x64 configurations, the hashing function triggers this failure: Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data. If this was intentional, you should mask the source of the cast with the appropriate bitmask. This is similar to the integer sanitizer - this code is valid C++ but MSVC decides to warn about this nonetheless. Masking the pointer's low 32 bits fixes the issue. Fixes #357.
This commit is contained in:
parent
a196b9b7e9
commit
23ca940487
@ -378,7 +378,7 @@ PUGI__NS_BEGIN
|
|||||||
|
|
||||||
static PUGI__UNSIGNED_OVERFLOW unsigned int hash(const void* key)
|
static PUGI__UNSIGNED_OVERFLOW unsigned int hash(const void* key)
|
||||||
{
|
{
|
||||||
unsigned int h = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(key));
|
unsigned int h = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(key) & 0xffffffff);
|
||||||
|
|
||||||
// MurmurHash3 32-bit finalizer
|
// MurmurHash3 32-bit finalizer
|
||||||
h ^= h >> 16;
|
h ^= h >> 16;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user