lua-users home
lua-l archive

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


> The lua_tounsigned() function boils down to lua_tounsignedx(), which then
> calls lua_number2unsigned(), which is defined as:
> 
> #define lua_number2unsigned(i,n)    ((i)=(lua_Unsigned)(n))
> 
> This type of cast is undefined behaviour - see
> [...]

This is not the default definition for lua_number2unsigned. The
default is this one:

#define SUPUNSIGNED     ((lua_Number)(~(lua_Unsigned)0) + 1)
#define lua_number2unsigned(i,n)  \
        ((i)=(lua_Unsigned)((n) - floor((n)/SUPUNSIGNED)*SUPUNSIGNED))

which should have a defined behavior...

Can you give more information about this?

-- Roberto