diff --git a/src/header/wchar/mod.rs b/src/header/wchar/mod.rs index ff21b4eebc..08edbf3374 100644 --- a/src/header/wchar/mod.rs +++ b/src/header/wchar/mod.rs @@ -875,9 +875,27 @@ macro_rules! strtou_impl { { let new = result.checked_mul(base as $type).and_then(|result| { if $negative { - result.checked_sub(digit as $type) + #[cfg(target_arch = "x86")] + { + result.checked_sub( + $type::try_from(digit).expect("single digit never overflows"), + ) + } + #[cfg(not(target_arch = "x86"))] + { + result.checked_sub($type::from(digit)) + } } else { - result.checked_add(digit as $type) + #[cfg(target_arch = "x86")] + { + result.checked_add( + $type::try_from(digit).expect("single digit never overflows"), + ) + } + #[cfg(not(target_arch = "x86"))] + { + result.checked_add($type::from(digit)) + } } }); result = match new {