[PATCH] Fixes sentinel warnings on GCC4
Chris Shoemaker
c.shoemaker at cox.net
Mon Dec 5 18:47:57 EST 2005
On Mon, Dec 05, 2005 at 06:28:00PM -0500, Chris Shoemaker wrote:
> You misunderstand me. This *is* a problem, and we *should* fix it.
> Our code is just *wrong*. It's wrong on 32-bit machines and on 64-bit
> machines. (Although it happens to be a benign bug anywhere ((char *)
> NULL) is a 32-bit zero, which is almost everywhere.) It's just wrong
> C. '0' is only equivalent to the typed null pointer in a pointer
> context (that's even true when a typed null pointer is not a 32-bit
> null; it's part of the language definition of a null pointer.) An
^^^^^
err, that should be "zero". I can't seem to find a online copy of
the ANSI C standard but google turned up several portability guides
that make this same point. Here's one:
http://www.psgd.org/paul/docs/cport/cport11.htm
Notice that constant zero is not always equal to a value of zero.
-chris
> argument list to a variadic function is no different than a function
> with no prototype - the arguments are NOT in pointer context.
>
> The C-language rule is "always cast NULL when used as a sentinel to a
> variadic function, otherwise you're accidentally passing integer
> zero, which is wrong."
>
> -chris
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
More information about the gnucash-devel
mailing list