[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Lua 5.2.0 (rc4) now available
- From: Miles Bader <miles@...>
- Date: Fri, 02 Dec 2011 14:58:23 +0900
"Dimiter \"malkia\" Stanev" <email@example.com> writes:
> That's what I thought, until I stumbled onto this article:
> The problem arises when varargs are used, so lua might (haven't checked)
> not be hitting the issue.
That's a different situation -- a varargs argument is not "in a
pointer context", so the compiler doesn't have enough information to
do the implicit conversion which it normally does. A similar case
occurs for function calls without a prototype in scope (but such usage
is increasingly rare these days). Note that a similar caveat occurs
for many other types -- one can write "extern void f(float); f (5);"
and the compiler will convert "5" to a float, but in a varargs context
(or for a function without a prototype), one has to explicitly write
However in a pointer-context, the compiler _does_ have enough
information, and using "0" is perfectly correct.
[The varargs-sentinel case is one reason it's useful in C to define
NULL as "(void*)0", but it's perfectly reasonable to use 0 in normal
cases, and "(some_type*)0" in the null-sentinel case.]
Anyway, the immediate issue is whether the Lua source code's use of
"0" for a null-pointer is valid or not, and it seems pretty clear to
me that it is -- and the OP's compiler is incorrect in emitting a
warning for such usage (almost by definition: if it has enough
information to emit the warning, it usually has enough information to
do the implicit conversion).
Cat, n. A soft, indestructible automaton provided by nature to be kicked when
things go wrong in the domestic circle.