Skip to content
Snippets Groups Projects
Unverified Commit 3026aec9 authored by Rodrigo Locatti's avatar Rodrigo Locatti Committed by GitHub
Browse files

Merge pull request #3106 from lioncash/bitfield

common/bit_field: Silence sign-conversion warnings
parents a8295d2c 14581e4a
No related branches found
No related tags found
No related merge requests found
...@@ -135,7 +135,8 @@ public: ...@@ -135,7 +135,8 @@ public:
/// Constants to allow limited introspection of fields if needed /// Constants to allow limited introspection of fields if needed
static constexpr std::size_t position = Position; static constexpr std::size_t position = Position;
static constexpr std::size_t bits = Bits; 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<StorageType>::max() >> (8 * sizeof(T) - bits)) << position);
/** /**
* Formats a value by masking and shifting it according to the field parameters. A value * Formats a value by masking and shifting it according to the field parameters. A value
...@@ -143,7 +144,7 @@ public: ...@@ -143,7 +144,7 @@ public:
* the results together. * the results together.
*/ */
static constexpr FORCE_INLINE StorageType FormatValue(const T& value) { static constexpr FORCE_INLINE StorageType FormatValue(const T& value) {
return ((StorageType)value << position) & mask; return (static_cast<StorageType>(value) << position) & mask;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment