lua-users home
lua-l archive

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


On Sep 27, 2012, at 4:24 PM, William Ahern <william@25thandClement.com> wrote:

> On Wed, Sep 26, 2012 at 03:17:41PM +0200, jean-luc@zenocloud.eu wrote:
>> Hi,
>> 
>> 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.
>> 
> 
> Sorry for beating a dead horse, but I was actually trying to track down the
> issue in the clang source code. However, I can't reproduce this warning with
> clang 4.1. What flags are you using? I can't get it with -Wall -Wextra.

Try -Wconversion or, more specifically, -Wshorten-64-to-32.