From 14581e4a59cfe983cae397850a091d866eee045c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 13 Nov 2019 14:41:24 -0500 Subject: common/bit_field: Silence sign-conversion warnings We can just use numeric_limits instead of relying on wraparound behavior here. --- src/common/bit_field.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/common/bit_field.h b/src/common/bit_field.h index fd2bbbd99..2dbe37839 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -135,7 +135,8 @@ public: /// Constants to allow limited introspection of fields if needed static constexpr std::size_t position = Position; static constexpr std::size_t bits = Bits; - static constexpr StorageType mask = (((StorageType)~0) >> (8 * sizeof(T) - bits)) << position; + static constexpr StorageType mask = StorageType( + (std::numeric_limits::max() >> (8 * sizeof(T) - bits)) << position); /** * Formats a value by masking and shifting it according to the field parameters. A value @@ -143,7 +144,7 @@ public: * the results together. */ static constexpr FORCE_INLINE StorageType FormatValue(const T& value) { - return ((StorageType)value << position) & mask; + return (static_cast(value) << position) & mask; } /** -- cgit v1.2.3