ryancbuckley opened issue #15198:
Minor/pedantic bug. The float-to-int128 conversions in the interpreter misbehave when passed very large (or very negative) values:
- fcvt_to_sint.i128 returns i128::MAX or i128::MIN for out-of-range inputs. The doc comments say it should trap.
- fcvt_to_uint.i128 and fcvt_to_uint_sat.i128 clamp some large inputs (in the interval [2¹²⁷, 2¹²⁸)) to i128::MAX, even though those values should fit in the result.
I noticed this issue because runtests/i128-conversion.clif matches the implementation, so it has three incorrect expectations:
- Line 14:
; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should return: 340282346638528859811704183484516925440
- The nearly identical call on line 40 should have the same result:
; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Line 28:
; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should trap
The root cause is that the interpreter's fcvt_to_uint and fcvt_to_sint cast the input with
as i128before the bounds check (step.rs#L1072).
ryancbuckley added the bug label to Issue #15198.
ryancbuckley added the cranelift label to Issue #15198.
ryancbuckley edited issue #15198:
Minor/pedantic bug. The float-to-int128 conversions in the interpreter misbehave when passed very large (or very negative) values:
- fcvt_to_sint.i128 returns i128::MAX or i128::MIN for out-of-range inputs. The doc comments say it should trap.
- fcvt_to_uint.i128 and fcvt_to_uint_sat.i128 clamp some large inputs (in the interval [2¹²⁷, 2¹²⁸)) to i128::MAX, even though those values should fit in the result.
I noticed this issue because runtests/i128-conversion.clif matches the implementation, so it has three incorrect expectations:
- Line 14:
; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should return: 340282346638528859811704183484516925440
- The nearly identical call on line 40 should have the same result:
; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Line 28:
; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should trap
The root cause is that the interpreter's fcvt_to_uint and fcvt_to_sint cast the input with
as i128before the bounds check.
cfallin closed issue #15198:
Minor/pedantic bug. The float-to-int128 conversions in the interpreter misbehave when passed very large (or very negative) values:
- fcvt_to_sint.i128 returns i128::MAX or i128::MIN for out-of-range inputs. The doc comments say it should trap.
- fcvt_to_uint.i128 and fcvt_to_uint_sat.i128 clamp some large inputs (in the interval [2¹²⁷, 2¹²⁸)) to i128::MAX, even though those values should fit in the result.
I noticed this issue because runtests/i128-conversion.clif matches the implementation, so it has three incorrect expectations:
- Line 14:
; run: %fcvt_to_uint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should return: 340282346638528859811704183484516925440
- The nearly identical call on line 40 should have the same result:
; run: %fcvt_to_uint_sat_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Line 28:
; run: %fcvt_to_sint_i128(0x1.fffffep127) == 170141183460469231731687303715884105727- Should trap
The root cause is that the interpreter's fcvt_to_uint and fcvt_to_sint cast the input with
as i128before the bounds check.
Last updated: Nov 19 2026 at 20:05 UTC