Skip to content

Commit

Permalink
Silence more visual studio warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Mar 26, 2018
1 parent 46f0214 commit 9edfce5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions util/bit_packing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ typedef union { float f; uint32_t i; } FloatEnc;

inline float ReadFloat32(const void *base, uint64_t bit_off) {
FloatEnc encoded;
encoded.i = ReadOff(base, bit_off) >> BitPackShift(bit_off & 7, 32);
encoded.i = static_cast<uint32_t>(ReadOff(base, bit_off) >> BitPackShift(bit_off & 7, 32));
return encoded.f;
}
inline void WriteFloat32(void *base, uint64_t bit_off, float value) {
Expand All @@ -135,7 +135,7 @@ inline void UnsetSign(float &to) {

inline float ReadNonPositiveFloat31(const void *base, uint64_t bit_off) {
FloatEnc encoded;
encoded.i = ReadOff(base, bit_off) >> BitPackShift(bit_off & 7, 31);
encoded.i = static_cast<uint32_t>(ReadOff(base, bit_off) >> BitPackShift(bit_off & 7, 31));
// Sign bit set means negative.
encoded.i |= kSignBit;
return encoded.f;
Expand Down
2 changes: 1 addition & 1 deletion util/exception.hh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class OverflowException : public Exception {

template <unsigned len> inline std::size_t CheckOverflowInternal(uint64_t value) {
UTIL_THROW_IF(value > static_cast<uint64_t>(std::numeric_limits<std::size_t>::max()), OverflowException, "Integer overflow detected. This model is too big for 32-bit code.");
return value;
return static_cast<std::size_t>(value);
}

template <> inline std::size_t CheckOverflowInternal<8>(uint64_t value) {
Expand Down

0 comments on commit 9edfce5

Please sign in to comment.