Skip to content

Commit 2aeb50e

Browse files
authored
Merge pull request #1528 from malaterre/shift-count-overflow
Prefer fixed-width integer types instead of size_t
2 parents cbcf15f + ae5b766 commit 2aeb50e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

openvdb_ax/openvdb_ax/codegen/StandardFunctions.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace
4949
// that fit into an unsigned int, and then shift those bytes out of the
5050
// hash. We repeat until we have no bits left in the hash.
5151
template <typename SeedType>
52-
inline SeedType hashToSeed(size_t hash) {
52+
inline SeedType hashToSeed(uint64_t hash) {
5353
SeedType seed = 0;
5454
do {
5555
seed ^= (SeedType) hash;
@@ -955,7 +955,7 @@ inline FunctionGroup::UniquePtr axrand32(const FunctionOptions& op)
955955
// (e.g. -0 and +0 must return the same hash value, etc). Other than these
956956
// special cases, this function will usually just copy the binary
957957
// representation of a float into the resultant `size_t`
958-
const size_t hash = std::hash<double>()(seed);
958+
const uint64_t hash = std::hash<double>()(seed);
959959

960960
// Now that we have a reliable hash (with special floating-point cases taken
961961
// care of), we proceed to use this hash to seed a random number generator.

openvdb_ax/openvdb_ax/test/integration/TestStandardFunctions.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ TestStandardFunctions::rand()
11661166
void
11671167
TestStandardFunctions::rand32()
11681168
{
1169-
auto hashToSeed = [](size_t hash) ->
1169+
auto hashToSeed = [](uint64_t hash) ->
11701170
std::mt19937::result_type
11711171
{
11721172
unsigned int seed = 0;

0 commit comments

Comments
 (0)