MSVC warnings when compiling Lua as C++

"'Sainan' via lua-l" <[email protected]> Wed, 29 Jul 2026 12:21:43 +0000
Newsgroups gmane.comp.lang.lua.general
Message-ID <_X7GkU3ewTzgcrEJ-peawS3Vj_bOlnCs-E-qbWZsFnc_HEwwcrYuHCLsUVSV8eB80kTf-Dt78wgXtYmgYxIjwSW3DBg5ldc2hrY_DIldK1U=@calamity.inc>
Hi, I feel like this topic is brought up every so often and not like it's m=
ajorly 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 implic=
itly converted to 64 bits (was 64-bit shift intended?)
1>...\lua\lgc.c(577,21): warning C4334: '<<': result of 32-bit shift implic=
itly converted to 64 bits (was 64-bit shift intended?)
1>...\lua\lgc.c(792,19): warning C4334: '<<': result of 32-bit shift implic=
itly converted to 64 bits (was 64-bit shift intended?)
1>...\lua\lgc.c(811,23): warning C4334: '<<': result of 32-bit shift implic=
itly converted to 64 bits (was 64-bit shift intended?)
1>...\lua\ltable.c(389,10): warning C4334: '<<': result of 32-bit shift imp=
licitly 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.

--=C2=A0Sainan

--=20
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 e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/_X7Gk=
U3ewTzgcrEJ-peawS3Vj_bOlnCs-E-qbWZsFnc_HEwwcrYuHCLsUVSV8eB80kTf-Dt78wgXtYmg=
YxIjwSW3DBg5ldc2hrY_DIldK1U%3D%40calamity.inc.