Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!brl-tgr!gwyn From: gwyn@brl-tgr.ARPA (Doug Gwyn ) Newsgroups: net.lang.c Subject: Re: if (p), where p is a pointer (REAL portability) Message-ID: <1467@brl-tgr.ARPA> Date: Fri, 13-Sep-85 09:04:23 EDT Article-I.D.: brl-tgr.1467 Posted: Fri Sep 13 09:04:23 1985 Date-Received: Sat, 14-Sep-85 16:55:14 EDT References: <118@mit-hector.UUCP> <4300@alice.UUCP> <11610@rochester.UUCP> Organization: Ballistic Research Lab Lines: 33 > I have to disagree with A. Koenig's reply. The rules he cites are > accurate, but the conclusions are unsafe. Sorry, Stu, but Andy was completely correct and you are wrong. > A constant zero IS safely converted into a "null" pointer of the > appropriate type. IT IS NOT THE CASE that a "null" pointer of an > arbitrary type is converted to or represented by all zero bits. No one said anything about representing a null pointer by "zero bits". The integer constant 0, written in the source code, is guaranteed to compare equal to a null pointer, and there are some other guarantees (NOT including bit pattern for a null pointer). > char *p; > if (p) /* NOT PORTABLE */ Rong. > Moreover, saying that NULL must be defined as zero is putting the cart > before the horse. NULL must be defined as an invalid (char *) pointer > and if your machine architecture wants that to be 0x555555, then that > is what NULL should be defined as. It is coincidental and NONPORTABLE > that NULL is usually defined as 0. Rong. The only portable definition of NULL is as 0. > NULL is NOT guaranteed to be canonical "null" pointer for any type > other than (char *). Where did you get this idea? Please read the X3J11 information bulletin.