mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-11 13:34:06 +00:00
Fix potential integer overflow in test::hash<int>
This commit is contained in:
parent
2c1c99407e
commit
47e205487d
@ -230,18 +230,18 @@ namespace test {
|
||||
|
||||
std::size_t operator()(int x) const
|
||||
{
|
||||
int result;
|
||||
unsigned result;
|
||||
switch (type_) {
|
||||
case 1:
|
||||
result = x;
|
||||
result = static_cast<unsigned>(x);
|
||||
break;
|
||||
case 2:
|
||||
result = x * 7;
|
||||
result = static_cast<unsigned>(x) * 7;
|
||||
break;
|
||||
default:
|
||||
result = x * 256;
|
||||
result = static_cast<unsigned>(x) * 256;
|
||||
}
|
||||
return static_cast<std::size_t>(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
friend bool operator==(hash const& x1, hash const& x2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user