I am compiling from the latest commit on the mirror repository hosted on github.
I think this is just MSVC being ridiculous. I did browse a bit
about this warning and stumbled upon this:
https://developercommunity.visualstudio.com/t/warning-c6001c4701-false-positive/1580097
The response the user got is that "it is too complex" to solve
this.
Example provided by the user still fails 4 years later on the
latest MSVC (https://godbolt.org/z/3bMb5Y5vT).
But then I can't possibly understand how it doesn't emit warning
here for 'flim':
...
lua_Number flim; /* try to convert to float */
if (!tonumber(lim, &flim)) /* cannot convert to float? */
luaG_forerror(L, lim, "limit");
/* else 'flim' is a float out of integer bounds */
if (luai_numlt(0, flim)) { /* if it is positive, it is too large */
if (step < 0) return 1; /* initial value must be less than it */
*p = LUA_MAXINTEGER; /* truncate */
}
...
Anyways the only legit warning from MSVC here is I think for 'args' when 'l_noret' is void:
...
expdesc args;
int base, nparams;
int line = ls->linenumber;
switch (ls->t.token) {
case '(': { /* funcargs -> '(' [ explist ] ')' */
luaX_next(ls);
if (ls->t.token == ')') /* arg list is empty? */
args.k = VVOID;
else {
explist(ls, &args);
if (hasmultret(args.k))
luaK_setmultret(fs, &args);
}
check_match(ls, ')', '(', line);
break;
}
case '{' /*}*/: { /* funcargs -> constructor */
constructor(ls, &args);
break;
}
case TK_STRING: { /* funcargs -> STRING */
codestring(&args, ls->t.seminfo.ts);
luaX_next(ls); /* must use 'seminfo' before 'next' */
break;
}
default: {
luaX_syntaxerror(ls, "function arguments expected");
}
}
lua_assert(f->k == VNONRELOC);
base = f->u.info; /* base register for call */
if (hasmultret(args.k))
...
Can anyone explain this warning? The recursive call is guarded by two
if's, and it calls the function with a different argument (L in the
original call, mainth in the recursive call). How can the compiler decide
that the recursion is infinite?
Can anyone explain this warning? The recursive call is guarded by two
if's, and it calls the function with a different argument (L in the
original call, mainth in the recursive call). How can the compiler decide
that the recursion is infinite?
More exactly: the recursive call only happens if L->errorJmp is nil.
But then it is done with a new L (mainth) which errorJmp field is not
nil. So, it seems quite easy to prove that the recursive call happens at
most once. Or am I missing something?