bug-gnulib
[Top][All Lists]
Advanced

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

Re: 0 vs. NULL


From: Micah Cowan
Subject: Re: 0 vs. NULL
Date: Mon, 15 Oct 2007 14:40:13 -0700
User-agent: Thunderbird 1.5.0.13 (X11/20070824)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Paul Eggert wrote:
> Bruno Haible <address@hidden> writes:
> 
>> Compilers such as Sun C++ really define NULL to 0
>> (in both C and C++ mode!), and misinterpret NULL in varargs and sizeof.
> 
> The problem with varargs is one that has bitten me personally.  Ouch!
> 
> But "sizeof (NULL)" is a new one on me.  As near as I can make out,
> that expression can yield any nonnegative value, as far as the C
> standard is concerned.  I'd be mildly surprised to find any useful,
> portable code that contains "sizeof (NULL)"; normally I would think
> "bug" if I saw such an expression.
> 
> This is a trivial point by itself, but I'm raising it since I'm a bit
> worried that I am missing something nontrivial here.

I'm pretty sure that Bruno was using "sizeof (NULL)" to demonstrate that
GNU C++ manages to use a special 0-valued constant that is (presumably)
compatible with pointer-types, while not actually _having_ a pointer
type (or, at least, not requiring a cast). I don't think anyone was
suggesting that "sizeof (NULL)" be actually used anywhere. :)

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHE9497M8hyUobTrERCGY6AJ45nSyE3y1g7bK6INLGvPdjhbNKcgCfZ8GO
b40144Y29KqFzvXVaLatQ8w=
=dG2Q
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]