Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Re: Casting call Message-ID: <2224@sun.uucp> Date: Sat, 25-May-85 16:13:47 EDT Article-I.D.: sun.2224 Posted: Sat May 25 16:13:47 1985 Date-Received: Thu, 30-May-85 00:23:42 EDT References: <10946@brl-tgr.ARPA> <4@ucbcad.UUCP> Organization: Sun Microsystems, Inc. Lines: 21 > The original problem was that NULL is a valid address under 4.{2,3}, > but (char *) -1 isn't. This is, of course, dependent on 4.2 and > the VAX. The accident of implementation that makes the result of casting NULL into a pointer be a value that does point to a mapped portion of your address space doesn't justify using (char *) -1 as a special sentinel value for pointers, instead of NULL. On PDP-11 UNIX, an accident of implementation makes the result of casting -1 into a pointer point to a mapped *and* writable portion of your address space. On VAX System V Release 2 Version 2, on 3B System V Release 2 Version Whatever-Gives-You-Demand-Paging, on Vax 4.2BSD As Modified By John Bruner, on Sun UNIX, on CCI Power 5/20 UNIX, on VAX/VMS, and on lots of other implementations, either the address space is set up so that the result of casting NULL into a pointer does not point to a mapped portion of your address space or you can ask that the address space be so set up. Moral: use the language the way it's supposed to be used, and you're better off. Guy Harris