fixes #18540; union casts for float conv

This commit is contained in:
ringabout
2024-07-31 20:29:03 +08:00
parent 39629a1adc
commit a2fbf13e2d
2 changed files with 45 additions and 20 deletions

14
tests/c/tconv.nim Normal file
View File

@@ -0,0 +1,14 @@
discard """
matrix: "-d:danger;"
targets: "c cpp"
"""
block: # bug #18540
block:
let num = 256.1
doAssert ord(uint8(num)) == 154
block:
let num = 255.0
doAssert ord(char(num)) == 0
let z = char(num)
doAssert ord(z) == 0