lua-users home
lua-l archive

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


I migrated from Lua 5.2.0 to Lua 5.2.1 this morning. It went really smoothly but with some compiler warnings, hence this message.

So, compiling Lua 5.2.1 on OS X (x86_64) with LLVM compiler 4.1 produces these 2 warnings:

- lstring.c:52:25: warning: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int'

   51 unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
>> 52   unsigned int h = seed ^ l;
   53   size_t l1;
   54  size_t step = (l >> LUAI_HASHLIMIT) + 1;

- lstate.c:91:20: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'unsigned int'

   89 static unsigned int makeseed (lua_State *L) {
   90  char buff[4 * sizeof(size_t)];
>> 91  unsigned int h = luai_makeseed();
   92  int p = 0;
   93  addbuff(buff, p, L);  /* heap variable */

Both warnings are caused to narrowing conversions of size_t (64 bits) into unsigned int (32 bits) on the architecture.
They can be easily removed by adding explicit conversion to (unsigned int) in these two lines.