aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/ir.cpp
diff options
context:
space:
mode:
authorEvan Haas <evan@lagerdata.com>2020-12-23 20:46:46 -0800
committerVeikka Tuominen <git@vexu.eu>2020-12-25 14:38:31 +0200
commit830bc41b1f71d5366037f3944d35618d8ca46e51 (patch)
treec253e0e2c163bf1f221930232aff4297924ed2a4 /src/stage1/ir.cpp
parent9f33984119ee698a9b344ad0df7b498b334e0f6e (diff)
downloadzig-830bc41b1f71d5366037f3944d35618d8ca46e51.tar.gz
zig-830bc41b1f71d5366037f3944d35618d8ca46e51.zip
Correctly cast bool to signed int in translate-c
Previously casting a bool to an int would result in the following Zig code: @intCast(c_int, @bitCast(i1, @intCast(u1, @boolToInt(b)))); This is incorrect if `b` is true, since bitcasting a `u1` with the value 1 to an `i1` will result in the value -1. Instead, generate the following code: @as(c_int, @boolToInt(b)); Since @boolToInt returns a `u1`, this is only disallowed if the destination type is one-bit and signed, which can only happen if it's a bitfield (currently not supported by translate-c)
Diffstat (limited to 'src/stage1/ir.cpp')
0 files changed, 0 insertions, 0 deletions