Cosmin Apreutesei
2014-08-11 14:16:17 UTC
Hi,
The following code fails with jit on, but works with jit off (luajit
2.0.3 and 2.1, 32bit and 64bit).
local ffi = require'ffi'
local buf = ffi.new'uint32_t[1]'
local p = ffi.cast('uint32_t*', buf)
local c = -0x80000000
for i = 1,1000 do --wait for the jit to kick in
p[0] = c
end
print(string.format('0x%x', p[0])) --should be 0x8000 0000 but it's 0
PS: Probably not related, but in 64bit mode, string.format('0x%x',
bit.lshift(128, 24)) prints 0xffff ffff 8000 0000 although
print(bit.lshift(128, 24)) shows -2147483648.
Thanks.
The following code fails with jit on, but works with jit off (luajit
2.0.3 and 2.1, 32bit and 64bit).
local ffi = require'ffi'
local buf = ffi.new'uint32_t[1]'
local p = ffi.cast('uint32_t*', buf)
local c = -0x80000000
for i = 1,1000 do --wait for the jit to kick in
p[0] = c
end
print(string.format('0x%x', p[0])) --should be 0x8000 0000 but it's 0
PS: Probably not related, but in 64bit mode, string.format('0x%x',
bit.lshift(128, 24)) prints 0xffff ffff 8000 0000 although
print(bit.lshift(128, 24)) shows -2147483648.
Thanks.