lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> build Lua 5.3.0 work2 with gcc -O3 -Wall produce this warning:
> gcc -O3 -Wall -Wextra -DLUA_COMPAT_ALL -DLUA_BUILD_AS_DLL    -c -o lvm.o
> lvm.c
> lvm.c: In function 'luaV_equalobj':
> lvm.c:223:22: warning: 'n2' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>        lua_Number n1, n2;
>                       ^
> In file included from lua.h:16:0,
>                  from lvm.c:16:
> luaconf.h:511:30: warning: 'n1' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>  #define luai_numeq(a,b)  ((a)==(b))
>                               ^
> lvm.c:223:18: note: 'n1' was declared here
>        lua_Number n1, n2;
>                   ^
> Is that worth to fix? (-O3 is unsafe optimize?)

I hate these compilers that try to be smart but are not smart enough.
(OK, it would need a small theorem prover, but we people can see that
'n2' cannot be used uninitialized without much ado...)

Can someone suggest a reasonable way to "fix" it without making the code
uglier and/or generating useless code? (It seems to me that anything
that makes the compiler believes that 'n2' will not be used uninitialized
will make readers believe that it could be used uninitialized otherwise,
which is wrong.)

-- Roberto