Re: using literal zero for NULL
- From: Behdad Esfahbod <behdad cs toronto edu>
- To: mikecorn <mikecorn t-online de>
- Cc: gtk-devel-list gnome org
- Subject: Re: using literal zero for NULL
- Date: Tue, 21 Mar 2006 03:50:51 -0500 (EST)
On Tue, 21 Mar 2006, 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?
There's no way for the compiler to know that the sentinel is
supposed to be a pointer. It's simply implemented as a varargs
function. Maybe we should emphasize the importance of using NULL
in our documentation.
--behdad
http://behdad.org/
"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
-- Dan Bern, "New American Language"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]