Skip to content

Commit 1fb8df6

Browse files
authored
Fix unsafe_trunc test for NaN16 (#56630)
The return value of the LLVM instruction `fptosi` (https://llvm.org/docs/LangRef.html#fptosi-to-instruction) does not guarantee that the truncation of `NaN` is 0, so we relax the test to only check that the output has the expected type. Fix #56582.
1 parent 873a1e4 commit 1fb8df6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

test/float16.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ end
7979
@test unsafe_trunc(Int16, Float16(3)) === Int16(3)
8080
@test unsafe_trunc(UInt128, Float16(3)) === UInt128(3)
8181
@test unsafe_trunc(Int128, Float16(3)) === Int128(3)
82-
@test unsafe_trunc(Int16, NaN16) === Int16(0) #18771
82+
# `unsafe_trunc` of `NaN` can be any value, see #56582
83+
@test unsafe_trunc(Int16, NaN16) isa Int16 # #18771
8384
end
8485
@testset "fma and muladd" begin
8586
@test fma(Float16(0.1),Float16(0.9),Float16(0.5)) fma(0.1,0.9,0.5)

0 commit comments

Comments
 (0)