Peter Colberg
2014-09-08 18:23:43 UTC
Hi,
The LuaJIT manual states [1] that
“Only the first field of a union can be initialized with a flat initializer.”
[1] http://luajit.org/ext_ffi_semantics.html#init
Running the following code with LuaJIT 2.0.3,
local ffi = require("ffi")
ffi.cdef [[
typedef union {
struct { double x, y, z, w; };
struct { double s0, s1, s2, s3; };
} cl_double4;
]]
local v = ffi.new("cl_double4", 1, 2, 3, 4)
print(v.x, v.y, v.z, v.w) --> 1 2 3 4
local v = ffi.new("cl_double4", 1, 2, 3, 4, 5, 6, 7, 8)
print(v.x, v.y, v.z, v.w) --> 5 6 7 8
I would expect that only the first anonymous struct is initialized,
and that the number of flat initializers is limited to 4. Shouldn’t
LuaJIT report an error "too many initializers" in the second case?
Thanks,
Peter
The LuaJIT manual states [1] that
“Only the first field of a union can be initialized with a flat initializer.”
[1] http://luajit.org/ext_ffi_semantics.html#init
Running the following code with LuaJIT 2.0.3,
local ffi = require("ffi")
ffi.cdef [[
typedef union {
struct { double x, y, z, w; };
struct { double s0, s1, s2, s3; };
} cl_double4;
]]
local v = ffi.new("cl_double4", 1, 2, 3, 4)
print(v.x, v.y, v.z, v.w) --> 1 2 3 4
local v = ffi.new("cl_double4", 1, 2, 3, 4, 5, 6, 7, 8)
print(v.x, v.y, v.z, v.w) --> 5 6 7 8
I would expect that only the first anonymous struct is initialized,
and that the number of flat initializers is limited to 4. Shouldn’t
LuaJIT report an error "too many initializers" in the second case?
Thanks,
Peter