On Sat, Mar 08, 2008 at 02:20:47PM +0000, Paul Walker wrote: > On Sat, Mar 08, 2008 at 02:53:51AM +0100, Vincent Lefevre wrote: > > > where X is an array. Moreover, gcc gives a warning for > > if (X == 0) > > but not for > > if (X == (void *) 0) > > This is completely unintuitive! > > Why is this unintuitive? > > X is a pointer. > 0 is *not* a pointer. It's an integer. > (void *)0 is a pointer. On Sat, Mar 08, 2008 at 03:30:18PM +0100, Thomas Roessler wrote: > On 2008-03-08 14:20:47 +0000, Paul Walker wrote: > > > Why wouldn't you? > > K&R, 2nd Ed, p. 102 > > Pointers and integers are not interchangeable. Zero is the > sole exception: the constant zero may be assigned to a > pointer, and a pointer may be compared with the constant zero. K&R says you can compare a pointer to the [integer] constant zero. (void*)0 is not a[n integer] constant, it's a void pointer. The warning is appropriate and does not conflict with K&R. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
Attachment:
pgp_9VCpa6Fx6.pgp
Description: PGP signature