[PATCH] Fixes sentinel warnings on GCC4

David Hampton hampton-gnucash at rainbolthampton.net
Mon Dec 5 20:39:15 EST 2005


On Mon, 2005-12-05 at 18:28 -0500, Chris Shoemaker wrote:
> On Mon, Dec 05, 2005 at 05:26:34PM -0500, Derek Atkins wrote:
> > 
> > ... we're still trying to analyze the issue and figure out what's really
> > going on.  I.e., there's no plan to make any changes until we understand
> > the problem.  David just went and tried to reproduce this on an amd64
> > machine and could not reproduce it.  Then we hear back that these errors
> > are on a 32-bit machine..  (all this is on IRC, and all in the last
> > few minutes)..   So..  We're still trying to figure out what the REAL
> > problem is before we consider this a gnucash  bug.

I checked the 32 bit Intel and 64 bit AMD systems that I have access to.
On all of these machines NULL is defined as "((void *)0)", and they all
compile gnucash cleanly.  The only way I can force these errors to occur
is to throw away the existing definition of NULL (as defined
in /usr/lib/gcc/<xxx>/4.0.2/include/stddef.h) and explicitly redefine
NULL to be an untyped "0".  Even then, I only see the problem occur when
compiling on an AMD64 system.  For that matter, to even elicit the error
I have to redefine NULL after all the system header files have been
included, or it is forced it back to the "((void*)0)" definition.

I have no explanation why Sjoerd is seeing this problem on a 32bit
system.  The only theory I can come up with is that his compiler is
treating C files as C++ files, and is thereby using a definition of NULL
as an untyped zero.  He would then also have to be compiling with the
-Wstrict-null-sentinel argument, which is only allowed for C++ compiles
and is specifically not included in the -Wall argument.

> You misunderstand me.  This *is* a problem, and we *should* fix it.

No, its not a problem and we do not need to fix anything. 

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

And as far as I can tell that's exactly what the GCC compiler provides
when compiling C code.  On 32 bit systems and 64 bit systems.

David




More information about the gnucash-devel mailing list