[Top][All Lists]
[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-----
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, (continued)
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Benoit SIGOURE, 2007/10/13
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Ben Pfaff, 2007/10/13
- Re: 0 vs. NULL (was: Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1), Bruno Haible, 2007/10/13
- Re: 0 vs. NULL, Micah Cowan, 2007/10/13
- Re: 0 vs. NULL, Bruno Haible, 2007/10/13
- Re: 0 vs. NULL, Paul Eggert, 2007/10/15
- Re: 0 vs. NULL,
Micah Cowan <=
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Jim Meyering, 2007/10/13
Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Simon Josefsson, 2007/10/13
Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Albert Chin, 2007/10/14