[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: various warnings in 5.1.4 and 5.2.0-work4 with icc/msvc64/splint
- From: David Manura <dm.lua@...>
- Date: Thu, 28 Oct 2010 21:41:58 -0400
On Thu, Oct 28, 2010 at 7:07 AM, Roberto Ierusalimschy
>> >> http://msdn.microsoft.com/en-us/library/ke55d167(v=VS.100).aspx ....
> It might be a coincidence, but all cases in your fixes the macro
> 'sizenode' was used in a context where it would naturally be converted
> to size_t. There are other cases where it should (or could) remain an int.
Although it's perfectly valid to implicitly convert an int into a
64-bit size_t, say by multiplying it by another size_t, MSVC -W3 is
complaining with C4334 when that int is formed by a variable left
shift on an integer literal. However, some trivial operation after
the shift avoids the warning:
#define twoto(x) (int)(1u<<(x)) /* note: unsigned->signed cast operation */
#define twoto(x) (int)(unsigned int)(1<<(x)) /* similar */
#define twoto(x) (0 | 1<<(x))
All of these eliminate the Lua 5.1.4 warnings. They do seem like hacks though.