Xref: utzoo comp.arch:4864 comp.lang.c:10177 Path: utzoo!attcan!uunet!tektronix!orca!tekecs!frip!andrew From: andrew@frip.gwd.tek.com (Andrew Klossner) Newsgroups: comp.arch,comp.lang.c Subject: Re: negative addresses Message-ID: <10001@tekecs.TEK.COM> Date: 17 May 88 17:57:43 GMT References: <2393@uvacs.CS.VIRGINIA.EDU> <21541@amdcad.AMD.COM> <1988May12.162906.16901@utzoo.uucp> <7881@brl-smoke.ARPA> Sender: andrew@tekecs.TEK.COM Organization: Tektronix, Wilsonville, Oregon Lines: 31 Doug Gwyn (gwyn@brl-smoke.ARPA) writes: >> Unfortunately, it is a real problem, because there are zillions of >> programs that implicitly assume that [null] pointers are all-zeros. > I don't think this is true. How about an example? Sure Doug, from the system V kernel that you defend so ardently :-), file io/tt1.c (vanilla release 3.1): In routine ttout: if (tbuf->c_ptr) appears twice. (And in the same routine, if (tbuf->c_ptr == NULL) appears twice. Multiple hackers have clogged through here.) In routine ttioctl: if (tp->t_rbuf.c_ptr) { if (tp->t_tbuf.c_ptr) { The C standards I've seen so far are pretty clear in stating that the conditional is compared against zero. There doesn't seem to be leeway to define pointer comparisons to be against some non-zero NULL value. -=- Andrew Klossner (decvax!tektronix!tekecs!andrew) [UUCP] (andrew%tekecs.tek.com@relay.cs.net) [ARPA]