Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!att!ulysses!andante!alice!debra From: debra@alice.UUCP (Paul De Bra) Newsgroups: comp.unix.wizards Subject: Re: Invalid Pointers (was Re: Referencing NULL pointers) Message-ID: <9622@alice.UUCP> Date: 17 Jul 89 13:46:32 GMT References: <20245@adm.BRL.MIL> <4348@eos.UUCP> Reply-To: debra@alice.UUCP () Organization: AT&T, Bell Labs Lines: 24 In article <4348@eos.UUCP> jbm@eos.UUCP (Jeffrey Mulligan) writes: } }It has been pointed out that there should be no assumptions }about what addresses are valid; is there any way to get }a guaranteed INVALID address? }... }So, the question is, how should NO_FOOBAR be defined? } }#define NO_FOOBAR ((struct foobar *) -1 ) is what I use, but... } }I note that malloc(3) returns NULL (0) on failure [on the sun], indicating }that 0 could never be a valid address returned from malloc. According to the (new) K&R book NULL (0) is indeed guaranteed not to be a valid data (or text or stack) address. Furthermore, the only meaningful comparisons between pointers are comparison between pointers to elements of the same string and comparison between a pointer and NULL. Paul. -- ------------------------------------------------------ |debra@research.att.com | uunet!research!debra | ------------------------------------------------------