lua-users home
lua-l archive

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


On Mon, Aug 3, 2009 at 12:26 PM, Luiz Henrique de
Figueiredo<lhf@tecgraf.puc-rio.br> wrote:
>> loslib.c (here loslib.cpp):
>> =static int os_exit (lua_State *L) {
>> =  exit(luaL_optint(L, 1, EXIT_SUCCESS));
>> +  return 0;
>> =}
>
> Other compilers know that exit never returns and complain that "return 0"
> is never reached. :-(
>
> http://lua-users.org/lists/lua-l/2002-06/msg00063.html
>
> It seems an unsolvable issue... (Note the dates!)

I'm curious about what you think of the solution provided in the 2002
thread here:
  http://lua-users.org/lists/lua-l/2002-06/msg00067.html
I was just about to suggest the same thing myself, and then discovered
it had already been suggested:

static int os_exit (lua_State *L) {
  if (L)
    exit(luaL_optint(L, 1, EXIT_SUCCESS));
  return 0;
}

This doesn't change the behavior of any well-formed Lua client, and
paying for one extra pointer test at os_exit() doesn't seem too steep
a cost to squash a warning.

Greg F