Re: MSVC warnings when compiling Lua as C++
Roberto Ierusalimschy <[email protected]> Wed, 29 Jul 2026 12:10:13 -0300
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
> Hi, I feel like this topic is brought up every so often and not like it's majorly urgent, but I'll just throw it here. > > As of the current latest commit (7579fc9d7ed90240487251dfb69168f8e64e9294), there's the following warnings when compiling Lua as C++ with MSVC: > > 1>...\lua\lgc.c(488,21): warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) [...] > > And my 2 cents for the patch; in lobject.h on line 829: > > -#define twoto(x) (1u<<(x)) > +#define twoto(x) (1ull<<(x)) > > This change results in these warnings disappearing. The point is that we do want a 32-bit shift. This warning seems to be a bug: In all those warnings, the result of the shift is being explicitly casted to size_t, which I believe is 64 bits. (Or not??) So, there is no "implicit" conversion to 64 bits. We really don't know how to silence this warning without worsening the code. -- Roberto -- You received this message because you are subscribed to the Google Groups "lua-l" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/lua-l/20260729151013.GB133473%40arraial.inf.puc-rio.br.