bug: FFI C function returns a struct instead of int

  • From: Anders Bergh <anders1@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 3 Feb 2013 00:41:33 +0100

Hi,

I found a reproducible bug in LuaJIT 2.0.0 as well as git HEAD (f772bed).

Here's the test case. Only tested on 64-bit LuaJIT running on OS X 10.8.2.

$ cat bug.lua
local ffi = require 'ffi'
ffi.cdef [[
struct timespec { int tv_sec; long tv_nsec; }
int nanosleep(const struct timespec *req, struct timespec *rem);
]]
local ret = ffi.C.nanosleep(ffi.new('struct timespec'), nil)
print(type(ret), ret)

$ luajit bug.lua
cdata   cdata<struct timespec>: 0x0004bb90

I expected ffi.C.nanosleep to return int, not a struct timespec.

Anders


Other related posts: