Re: MSVC and GCC compilation warnings

Jure Bagić <[email protected]> Thu, 30 Apr 2026 05:35:27 +0200
Newsgroups gmane.comp.lang.lua.general
Message-ID <afLNgc1t3wgEfnuA@archlinux>
On 26/04/29 03:51PM, Jure Bagić wrote:
> I recently setup a VM running Windows with a simple batch file to build Lua
> from source. Here is a complete list of warnings the Microsoft Vibe
> Coded Compiler emits.
> 
> In lobject.c:
> 
>     lobject.c(167) : potentially uninitialized local variable 'n1' used
>     lobject.c(167) : potentially uninitialized local variable 'n2' used
>     lobject.c(179) : potentially uninitialized local variable 'n1' used
>     lobject.c(179) : potentially uninitialized local variable 'n2' used
> 
> 
> The following are warnings for 'op_arithf_aux' macro in lvm.c:
> 
>     lvm.c(1445) : potentially uninitialized local variable 'n1' used
>     lvm.c(1445) : potentially uninitialized local variable 'n2' used
>     lvm.c(1449) : potentially uninitialized local variable 'n1' used
>     lvm.c(1449) : potentially uninitialized local variable 'n2' used
>     lvm.c(1453) : potentially uninitialized local variable 'n1' used
>     lvm.c(1453) : potentially uninitialized local variable 'n2' used
>     lvm.c(1458) : potentially uninitialized local variable 'n1' used
>     lvm.c(1458) : potentially uninitialized local variable 'n2' used
>     lvm.c(1462) : potentially uninitialized local variable 'n1' used
>     lvm.c(1462) : potentially uninitialized local variable 'n2' used
>     lvm.c(1466) : potentially uninitialized local variable 'n1' used
>     lvm.c(1466) : potentially uninitialized local variable 'n2' used
>     lvm.c(1471) : potentially uninitialized local variable 'n1' used
>     lvm.c(1471) : potentially uninitialized local variable 'n2' used
>     lvm.c(1507) : potentially uninitialized local variable 'n1' used
>     lvm.c(1507) : potentially uninitialized local variable 'n2' used
>     lvm.c(1511) : potentially uninitialized local variable 'n1' used
>     lvm.c(1511) : potentially uninitialized local variable 'n2' used
>     lvm.c(1515) : potentially uninitialized local variable 'n1' used
>     lvm.c(1515) : potentially uninitialized local variable 'n2' used
>     lvm.c(1520) : potentially uninitialized local variable 'n1' used
>     lvm.c(1520) : potentially uninitialized local variable 'n2' used
>     lvm.c(1524) : potentially uninitialized local variable 'n1' used
>     lvm.c(1524) : potentially uninitialized local variable 'n2' used
>     lvm.c(1528) : potentially uninitialized local variable 'n1' used
>     lvm.c(1528) : potentially uninitialized local variable 'n2' used
>     lvm.c(1533) : potentially uninitialized local variable 'n1' used
>     lvm.c(1533) : potentially uninitialized local variable 'n2' used
> 
> and the final one also in lvm.c:
> 
>     lvm.c(1595) : potentially uninitialized local variable 'nb' used
> 
> 
> Now, when the 'l_noret' is set as void, clang compiler emits no warnings.
> However, both gcc and msvc emit one warning each.
> 
> gcc:
> 
>     ldo.c:121:9: warning: infinite recursion detected [-Winfinite-recursion]
>       121 | l_noret luaD_throw (lua_State *L, TStatus errcode) {
>     ldo.c:132:7: note: recursive call
>       132 |       luaD_throw(mainth, errcode);  /* re-throw in main thread */
> 
> msvc:
> 
>     lparser.c(1171) : potentially uninitialized local variable 'args' used
> 
> 
> It would be nice to have additional macro directive for debug builds in
> definition of 'l_noret':
> 
>     #if !defined(l_noret)
> 
>     #if defined(LUAI_ASSERT)
>     #define l_noret               void
>     #elif defined(__GNUC__)
>     #define l_noret               void __attribute__((noreturn))
>     #elif defined(_MSC_VER) && _MSC_VER >= 1200
>     #define l_noret               void __declspec(noreturn)
>     #else
>     #define l_noret               void
>     #endif
> 
>     #endif
> 
> 
> The build was done via the attached batch file on MSVC 19.44.35213 for x64.
> The script builds the standalone interpreter 'lua.exe' and the library files 
> 'lua55.dll', 'lua55.exp' and 'lua55.lib'.
> It does not build the compiler ('luac.exe').
> 
> -- 
> Jure


Does anyone see this initial email?
I think it somehow got discarded, well, there it is.

-- 
Jure

-- 
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/afLNgc1t3wgEfnuA%40archlinux.
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQTilOnPIAgk+VLLAS+FaQJ4QtXaNQUCafLN/wAKCRCFaQJ4QtXa
NV60AQCpo1lYvy8i4xAm9cUhZ8JypliAmGw24IvkC6HTRCWzMQEA6xHSrfITFcys
hMLnKFRefHDGyO8eGbSywZx+xDjvIQE=
=QDmB
-----END PGP SIGNATURE-----