lua-users home
lua-l archive

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

In src/lauxlib.c  luaL_checkversion_ does the following test:
00952       lua_tounsigned(L, -1) != (lua_Unsigned)-0x1234)

lua_tounsigned does a cast from float to unsigned int. (I've compiled Lua to use float instead of double.) Casting a negative float value to unsigned int is undefined according to the C standard.

Does Lua really depend on the undefined behavior? Or is the test wrong.

In my case the test listed above fails with lua_tounsigned() returning 0 and (lua_Unsigned)-0x1234) returning 4294962636.