Warnings when compiling the Lua 5.3.5 interpreter by gcc version 7.4.0

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

Warnings when compiling the Lua 5.3.5 interpreter by gcc version 7.4.0

Dirk Laurie-2
I can't remember that this happened in 2017, but 'make linux' now gives:

lua.c: In function ‘runargs’:
lua.c:531:31: warning: passing argument 2 of ‘dolibrary’ discards
‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
                : dolibrary(L, extra);
                               ^~~~~
lua.c:259:12: note: expected ‘char *’ but argument is of type ‘const char *’
 static int dolibrary (lua_State *L, char *name) {
            ^~~~~~~~~

Reply | Threaded
Open this post in threaded view
|

Re: Warnings when compiling the Lua 5.3.5 interpreter by gcc version 7.4.0

Luiz Henrique de Figueiredo
> lua.c:259:12: note: expected ‘char *’ but argument is of type ‘const char *’
>  static int dolibrary (lua_State *L, char *name) {

The line number is right but the contents is not. In Lua 5.3.5, this line reads:

static int dolibrary (lua_State *L, const char *name) {

Reply | Threaded
Open this post in threaded view
|

Re: Warnings when compiling the Lua 5.3.5 interpreter by gcc version 7.4.0

Dirk Laurie-2
You are right. This buiild was not in a pristine Lua directory, but in
one that has been patched.

Sorry for the noise.

Op Do. 9 Mei 2019 om 18:47 het Luiz Henrique de Figueiredo
<[hidden email]> geskryf:
>
> > lua.c:259:12: note: expected ‘char *’ but argument is of type ‘const char *’
> >  static int dolibrary (lua_State *L, char *name) {
>
> The line number is right but the contents is not. In Lua 5.3.5, this line reads:
>
> static int dolibrary (lua_State *L, const char *name) {
>

Reply | Threaded
Open this post in threaded view
|

Re: Warnings when compiling the Lua 5.3.5 interpreter by gcc version 7.4.0

Vinicius Jarina
Kind of related, clang on macOS gives a few warning about the comma operator, and suggest cast it to void in order to avoid the warning.

                                ^
lua/src/ltablib.c:323:12: note: cast expression to void to silence warning
      while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) {
             ^~~~~~~~~~~~~~~~~~~
             (void)(            )
            
lua/src/liolib.c:42:28: note: cast expression to void to silence warning
           (*mode != '+' || (++mode, 1)) &&  /* skip if char is '+' */
                             ^~~~~~
                             (void)( )


On Thu, May 9, 2019 at 12:52 PM Dirk Laurie <[hidden email]> wrote:
You are right. This buiild was not in a pristine Lua directory, but in
one that has been patched.

Sorry for the noise.

Op Do. 9 Mei 2019 om 18:47 het Luiz Henrique de Figueiredo
<[hidden email]> geskryf:
>
> > lua.c:259:12: note: expected ‘char *’ but argument is of type ‘const char *’
> >  static int dolibrary (lua_State *L, char *name) {
>
> The line number is right but the contents is not. In Lua 5.3.5, this line reads:
>
> static int dolibrary (lua_State *L, const char *name) {
>