lua-users home
lua-l archive

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


On Mar 31, 2014, at 7:07 PM, Doug Currie <doug.currie@gmail.com> wrote:

> On Mon, Mar 31, 2014 at 7:18 PM, Paige DePol <lual@serfnet.org> wrote:
>  
> However, I also think that lua_checkstack() should have some sort of sanity check for negative values as the function does seem to assume that 'size' will always be zero or greater. Which new C99 features does it use, btw?
>  
> For C89, you may not have a declaration after the first statement in a block, so
> 
>   int res = 0;
>   if (size < 0) return res;  /* sanity check */
>   CallInfo *ci = L->ci;
> 
>  should be
> 
>   int res = 0;
>   CallInfo *ci = L->ci;
>   if (size < 0) return res;  /* sanity check */
> 
> or
> 
>   int res = 0;
>   CallInfo *ci;
>   if (size < 0) return res;  /* sanity check */
>   ci = L->ci;
> 
> You may be able to find these in your code with
> 
> -Wdeclaration-after-statement
> 
> e

Thank you for that information, I do appreciate it as I am not terribly well versed in the differences between the C standards. Most of my development is in Obj-C, with the use of C/C++ libraries where appropriate, so the standard used is always the latest one.

If I add that flag I do indeed get a warning for that line, however, if I do not use that specific flag but set the language dialect option to "ANSI C" or "C89" I do not get a warning.

~Paige