[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (beta-rc1) now available
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 14 Jun 2011 15:59:28 -0300
> >> 1) The macro twoto(x) defined as (1<<(x)) in lobject.h gives numerous
> >> warnings when building on MSVC for 64 bits platforms.
> >> The message is:
> >> warning C4334: '<<' : result of 32-bit shift implicitly converted
> >> to 64 bits (was 64-bit shift intended?)
> > This is strange. As '1' is an int, the result from the shift should be
> > an int, too.
> I think it's complaining that you're shifting in 32 bits, and then
> using the result only after conversion to 64 bits. (This probably
> comes from the sizenode macro.) I don't know how commonly this leads
> to actual errors in C code, but the warning would have saved me some
> momentary puzzlement when writing Java code.
It makes sense. In this case, we are sure the result fits in 32 bits,
and it will be used as 'int' several times. Patrick, can you check
whether this avoids the warnings?
#define twoto(x) ((int)(1<<(x)))
(It should show that we know that the result is 32 bits.)