From 71c9572e8bdcf05306e6df1fb3bd1afc924d2f83 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 21 Jul 2020 09:15:27 -0700 Subject: Fix i32.trunc_f64_s of values near the limit of f64 representation (#2968) See WebAssembly/spec#1223 --- src/support/safe_integer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/support/safe_integer.cpp') diff --git a/src/support/safe_integer.cpp b/src/support/safe_integer.cpp index d43f7a6aa..9b6b56be0 100644 --- a/src/support/safe_integer.cpp +++ b/src/support/safe_integer.cpp @@ -124,7 +124,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) { * 3 21098765432 1098...432109...210 * --------------------------------- * 0 00000000000 0000...000000...000 0x0000000000000000 => 0 - * 0 10000011101 1111...111000...000 0x41dfffffffc00000 => 2147483647 (INT32_MAX) + * 0 10000011101 1111...111000...111 0x41dfffffffffffff => 2147483647.9999998 (rounds down to INT32_MAX) * 0 10000011110 1111...111100...000 0x41efffffffe00000 => 4294967295 (UINT32_MAX) * 0 10000111101 1111...111111...111 0x43dfffffffffffff => 9223372036854774784 (~INT64_MAX) * 0 10000111110 0000...000000...000 0x43e0000000000000 => 9223372036854775808 @@ -146,7 +146,7 @@ bool wasm::isInRangeI64TruncU(int32_t i) { bool wasm::isInRangeI32TruncS(int64_t i) { uint64_t u = i; - return (u <= 0x41dfffffffc00000ULL) || + return (u <= 0x41dfffffffffffffULL) || (u >= 0x8000000000000000ULL && u <= 0xc1e0000000000000ULL); } -- cgit v1.2.3