[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (rc2) now available
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 28 Nov 2011 14:20:32 -0500
On Mon, Nov 28, 2011 at 12:51 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> >
>> > 277c277
>> > < exit(status);
>> > ---
>> > > return (exit(status), 0);
>>
>> That's an error because exit() doesn't return a value :-)
>>
>> I think in this case the compiler is wrong to produce the warning. Good
>> implementations have an annotation on exit() to say it never returns.
>> This is not a bug in Lua.
>
> The problem here is that this kind of annotation is not ANSI. So, some
> compilers have the annotation and rightfully complain when there is a
> return, and some do not have the annotation and rightfully (for their
> knowledge) complain when there is no return.
>
> Would this trick satisfy all compilers?
>
> diff -r1.35 loslib.c
> 277c277,278
> < exit(status);
> ---
>> if (L) exit(status); /* test to avoid warnings of 'exit' x 'return' */
>> return 0;
I think this would be foolproof:
lua_pushnumber(L, 0);
if (lua_isnumber(L, -1)) exit(status);
return 0;
--
- Patrick Donnelly