diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 80486a6e1a..4a2ef5baea 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -1000,7 +1000,7 @@ template requires (std::is_integral_v; // For unsigned/signed mismatch, create an "unsigned" compatible mask - constexpr auto from_mask = (is_from_signed && !is_to_signed) ? UnFrom{umax} >> 1 : UnFrom{umax}; + constexpr auto from_mask = (is_from_signed && !is_to_signed && sizeof(CommonFrom) <= sizeof(CommonTo)) ? UnFrom{umax} >> 1 : UnFrom{umax}; constexpr auto to_mask = (is_to_signed && !is_from_signed) ? UnTo{umax} >> 1 : UnTo{umax}; constexpr auto mask = static_cast(~(from_mask & to_mask)); @@ -1010,7 +1010,7 @@ template requires (std::is_integral_v(value) != static_cast(value)) [[unlikely]] + if (is_from_signed != is_to_signed ? !!(value & mask) : static_cast(static_cast(value)) != value) [[unlikely]] { fmt::raw_verify_error(src_loc, u8"Narrowing error", +value); }