Re: using literal zero for NULL



On Mon, 20 Mar 2006 23:53:35 -0800, mikecorn wrote:

> 
> I just tried rebuilding my GTK apps for a 64 bit Linux system (Fedora core
> 5), and had an ugly surprise: random segmentation faults. I traced at
> least one of them to my lazy habit of using a literal zero in place of
> NULL for an optional function argument or end-of-arg-list indicator. I
> speculate that the compiler is supplying a 32 bit zero where a 64 bit zero
> is needed. Correct? If so, it seems this is a compiler bug, since the type
> conversion should be automatic. Can someone confirm this?

The explanation for this has already been provided, but I thought I'd jump
in here and say that GCC has an __attribute__((sentinel)) that will
complain about this if you compile with -Wformat.

Perhaps gtk be using this on the relevant functions.





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