Fix Warning 'lua_Unsigned' to 'size_t'

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

Fix Warning 'lua_Unsigned' to 'size_t'

Vinicius Jarina
Hello

On Lua 5.3.x there is a warning on the function lua_rawlen 

warning C4244: 'return': conversion from 'lua_Unsigned' to 'size_t', possible loss of data

I know is harmless warning, but would be nice to add a cast so we could have 0 warnings building Lua from source.

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Fix Warning 'lua_Unsigned' to 'size_t'

Roberto Ierusalimschy
> On Lua 5.3.x there is a warning on the function lua_rawlen
> <https://github.com/lua/lua/blob/master/lapi.c#L396>

This link is not to Lua 5.3.x.


> warning C4244: 'return': conversion from 'lua_Unsigned' to 'size_t',
> possible loss of data
>
> I know is harmless warning, but would be nice to add a cast so we could
> have 0 warnings building Lua from source.

What is the compiler? What are the warning options? Are you sure
this is the only warning of this kind? (I think there are several
other instances of conversion from 'lua_Unsigned' or 'lua_Integer'
to 'size_t' in the code...)

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: Fix Warning 'lua_Unsigned' to 'size_t'

Vinicius Jarina
Visual Studio 2017

I've added a cast on my fork (this is a mirror from https://www.lua.org/versions.html#5.3 with the https://www.lua.org/bugs.html applied).

and this fixed the warning. But I don't really like to patch Lua, because then when Lua 5.4 final will be out I will need to repatch it.

Thank you Roberto.

On Wed, Jan 16, 2019 at 7:52 AM Roberto Ierusalimschy <[hidden email]> wrote:
> On Lua 5.3.x there is a warning on the function lua_rawlen
> <https://github.com/lua/lua/blob/master/lapi.c#L396>

This link is not to Lua 5.3.x.


> warning C4244: 'return': conversion from 'lua_Unsigned' to 'size_t',
> possible loss of data
>
> I know is harmless warning, but would be nice to add a cast so we could
> have 0 warnings building Lua from source.

What is the compiler? What are the warning options? Are you sure
this is the only warning of this kind? (I think there are several
other instances of conversion from 'lua_Unsigned' or 'lua_Integer'
to 'size_t' in the code...)

-- Roberto