From 46b8cfabc00a73df752ce68959efb55a8ac849e0 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Thu, 22 Jul 2021 13:16:27 -0700 Subject: [PATCH] bit_util: Protect Replicate from automatic up-casting Recursive calls to `Replicate` beyond the first call might cause an unintentional up-casting to an `int` type due to `|` and `<<` operations on types such as `uint8_t` and `uint16_t` This makes sure calls such as `Recursive` stay as the `u8` type through-out. --- src/dynarmic/common/bit_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dynarmic/common/bit_util.h b/src/dynarmic/common/bit_util.h index d05c2221..537753a9 100644 --- a/src/dynarmic/common/bit_util.h +++ b/src/dynarmic/common/bit_util.h @@ -203,7 +203,7 @@ constexpr T Replicate(T value, size_t element_size) { ASSERT_MSG(BitSize() % element_size == 0, "bitsize of T not divisible by element_size"); if (element_size == BitSize()) return value; - return Replicate(value | (value << element_size), element_size * 2); + return Replicate(T(value | value << element_size), element_size * 2); } template