[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Undefined behaviour in luaL_checkversion_()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 12 Sep 2012 11:03:51 -0300
> 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