Does lua really depend on undefined C behavior
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Does lua really depend on undefined C behavior
- From: JP <jpbonn-keyword-lua.054305@...>
- Date: 2012年1月26日 15:24:10 -0700
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.