Unverified Commit bfde1422 authored by Muhammed Fatih BALIN's avatar Muhammed Fatih BALIN Committed by GitHub
Browse files

[CUDA] Fix issue about integer overflow (#6586)

parent ee6dc9b6
...@@ -46,11 +46,13 @@ int _NumberOfBits(const T& range) { ...@@ -46,11 +46,13 @@ int _NumberOfBits(const T& range) {
} }
int bits = 1; int bits = 1;
while (bits < static_cast<int>(sizeof(T) * 8) && (1 << bits) < range) { while (bits < static_cast<int>(sizeof(T) * 8) && (1ull << bits) < range) {
++bits; ++bits;
} }
CHECK_EQ((range - 1) >> bits, 0); if (bits < static_cast<int>(sizeof(T) * 8)) {
CHECK_EQ((range - 1) >> bits, 0);
}
CHECK_NE((range - 1) >> (bits - 1), 0); CHECK_NE((range - 1) >> (bits - 1), 0);
return bits; return bits;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment