From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id LAA03594 for ; Mon, 27 May 1996 11:19:44 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id VAA17576; Sun, 26 May 1996 21:05:01 -0400 (EDT) Resent-Date: Sun, 26 May 1996 21:05:01 -0400 (EDT) From: Zoltan Hidvegi Message-Id: <199605270000.CAA00847@hzoli.ppp.cs.elte.hu> Subject: Re: (NULL == 0) ? To: A.Main@dcs.warwick.ac.uk (Zefram) Date: Mon, 27 May 1996 02:00:28 +0200 (MET DST) Cc: zsh-workers@math.gatech.edu (Zsh hacking and development) In-Reply-To: <15522.199605252200@stone.dcs.warwick.ac.uk> from Zefram at "May 25, 96 11:00:23 pm" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"KBqAP.0.VI4.z-Fgn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1182 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu > To answer the subject line, (NULL == 0) *is* guaranteed. 0 is the > representation of the null pointer constant in C. > > >I would be willing to bet money it's a non-unix box. Just think of > >the tremendous amount of unix code that uses the fact that calloc (in > >our case zcalloc) returns memory that is all zeros (and hence is > >NULL). Since zsh only works on unix boxes, I think zeroing out memory > >with memset is ok. > > A lot of C code assumes this, but it is broken. No Unix standard > guarantees more than the C standard about the representation of null > pointers. Does anything guarantees that on those (theoretical) systems where NULL is not really zero, all static and external pointers are initialized to this NULL? There are many many places where this assumption is used. Does anyone heard about such a Unix system? I bet that if such a system exists memset would be just the easiest among many other problems. A couple of other questions about Unix and C standards: does anything guarantee that a variable is always 8 * sizeof(var) bits long? Does any Unix or C standard guarantee that ASCII is used (zsh assumes ASCII in many places)? Does any Unix or C standard guarantees that an int always has at least 32 bits? Did anyone tried to compile zsh on a 80286 of 8086 Unix? I can imagine that NULL is not really zero on such systems but I doubt that zsh can be used on such a system anyway. Zoltan