lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> When using the ieee754 trick on an x86_64 machine where
> sizeof(lua_Integer) ==8 and sizeof(int) == 4, the following fails in
> 5.2 yet passes in 5.1
> 
> 		CPPUNIT_ASSERT(sizeof(lua_Integer) == 8);
> 		CPPUNIT_ASSERT(sizeof(int) == 4);
> 		lua_Integer input = 0x1ffffffff;
> 		lua_pushinteger(l, input );
> 		CPPUNIT_ASSERT_EQUAL(input,lua_tointeger(l,1));
> 
> 
> This is due to lua_number2integer when LUA_IEEE754TRICK is defined and
> called by lua_tointegerx
> #define lua_number2integer(i,n)		lua_number2int32(i, n, lua_Integer)

So, this is a bug, but I do not know what would be the best fix: to
change lua_number2integer to work correctly for 8 bytes or to change
lua_Integer to be a 4-byte integer.

-- Roberto