Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!rutgers!ames!ucbcad!ucbvax!decvax!ima!cfisun!palladium!nw From: nw@palladium.UUCP (Neil Webber) Newsgroups: comp.sys.amiga Subject: Re: Manx C Message-ID: <344@palladium.UUCP> Date: Fri, 7-Aug-87 20:02:32 EDT Article-I.D.: palladiu.344 Posted: Fri Aug 7 20:02:32 1987 Date-Received: Sun, 9-Aug-87 12:49:57 EDT References: <3199@zen.berkeley.edu> Distribution: comp Organization: Palladium Data Systems, Marlboro MA Lines: 42 In article <3199@zen.berkeley.edu>, waterman@cory.Berkeley.EDU (T.S. Alan Waterman) writes: > > if (ptr == 0) compares the pointer with an INT, which is gonna be 16 bits. > That is, is hacks ptr in half and compares the bottom half with 0 (16 bits). > If you don't expect your pointer to end up on such a huge page-boundary, > this'll work, but I wouldn't trust it.... > > if (!ptr) loads the thing into a register (all 32 bits of it) and checks > the zero flag. It doesn't run a cmp instruction. > > In short, the error message is correct. You are being rightly warned the the > compiler is about to do exactly what you told it to, and not really what > you wanted to do. > Sorry, but the Manx compiler is dead wrong here. In certain contexts, the symbol "0" DOES NOT MEAN INTEGER ZERO. It means "null pointer". The contexts that exhibit this property are exactly those contexts where the compiler knows that a pointer comparison or assignment is being performed. On the 68000: char *ptr; ptr = 0; /* 32 bit assignment of zeros to ptr */ if (ptr == 0) /* 32 bit comparison, Manx notwithstanding */ The size of an integer has nothing to do with it. The symbol "0" is special. Perhaps things would have been more clear if K & R had chosen some keyword, such as "nil", but they didn't. This is all spelled out quite well in K&R, H&S, as well as dpANS. If the Manx compiler insists on interpreting the meaning of those statements differently, it's a bug. I certainly don't plan to litter my code with junk like if (ptr == 0L) just because of a bug in Manx. -- Neil Webber / Palladium Data Systems / (No longer confused with Jordan Marsh) Marlboro MA, 01752 {linus!alliant, harvard!cfisun}!palladium!nw