lua-users home
lua-l archive

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


"Dimiter \"malkia\" Stanev" <malkia@gmail.com> writes:
> That's what I thought, until I stumbled onto this article:
>
> http://blog.slickedit.com/2011/05/things-i-learned-during-the-64-bit-port/
>
> 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
"5.0f".

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).

-Miles

-- 
Cat, n. A soft, indestructible automaton provided by nature to be kicked when
things go wrong in the domestic circle.