5.3.1 build warning

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

5.3.1 build warning

Chris Jones
Hey

When building Lua 5.3.1 on OS X with LLVM, I get the following warning:

lua/src/lvm.c:1128:58: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]

        b = luaD_poscall(L, ra, (b != 0 ? b - 1 : L->top - ra));

            ~~~~~~~~~~~~                          ~~~~~~~^~~~


This should be trivially fixable by casting L->top - ra to int.

IMHO this is worth doing because it's being implicitly converted anyway, and it's the only warning produced by the build :)

--
Cheers,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: 5.3.1 build warning

Roberto Ierusalimschy
> When building Lua 5.3.1 on OS X with LLVM, I get the following warning:
>
> lua/src/lvm.c:1128:58: warning: implicit conversion loses integer
> precision: 'long' to 'int' [-Wshorten-64-to-32]
>
>         b = luaD_poscall(L, ra, (b != 0 ? b - 1 : L->top - ra));
>
>             ~~~~~~~~~~~~                          ~~~~~~~^~~~
>
> This should be trivially fixable by casting L->top - ra to int.
>
> IMHO this is worth doing because it's being implicitly converted anyway,
> and it's the only warning produced by the build :)

It is funny that this compiler flags only this one. If I use
-Wconversion in my platform, I get 226 warnings similar to this one.

-- Roberto


Reply | Threaded
Open this post in threaded view
|

Re: 5.3.1 build warning

Chris Jones
Hi

On 24 June 2015 at 13:04, Roberto Ierusalimschy <[hidden email]> wrote:
It is funny that this compiler flags only this one. If I use
-Wconversion in my platform, I get 226 warnings similar to this one.

Interesting. FWIW, I seem to be building with: -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wunreachable-code -Wno-implicit-atomic-properties -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -Wprotocol -Wdeprecated-declarations -mmacosx-version-min=10.8 -g -Wno-sign-conversion 


--
Cheers,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: 5.3.1 build warning

Egor Skriptunoff-2
In reply to this post by Roberto Ierusalimschy
On Wed, Jun 24, 2015 at 3:04 PM, Roberto Ierusalimschy <[hidden email]> wrote:
> When building Lua 5.3.1 on OS X with LLVM, I get the following warning:
>
> lua/src/lvm.c:1128:58: warning: implicit conversion loses integer
> precision: 'long' to 'int' [-Wshorten-64-to-32]
>
>         b = luaD_poscall(L, ra, (b != 0 ? b - 1 : L->top - ra));
>
>             ~~~~~~~~~~~~                          ~~~~~~~^~~~
>
> This should be trivially fixable by casting L->top - ra to int.
>
> IMHO this is worth doing because it's being implicitly converted anyway,
> and it's the only warning produced by the build :)

It is funny that this compiler flags only this one. If I use
-Wconversion in my platform, I get 226 warnings similar to this one.

When building x64 executables of Lua 5.3.1 using MS Visual Studio the following 2 warnings are displayed:

lstrlib.c(839) : warning C4267: 'return' : conversion from 'size_t' to 'int', possible loss of data
lvm.c(1128) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data

-- Egor