Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!portal!cup.portal.com!Kevin_P_McCarty From: Kevin_P_McCarty@cup.portal.com Newsgroups: comp.lang.c Subject: Re: detecting invalid pointers Message-ID: <16039@cup.portal.com> Date: 20 Mar 89 06:47:02 GMT References: <15495@cup.portal.com> <11998@haddock.ima.isc.com> <3011@nunki.usc.edu> <12043@haddock.ima.isc.com> <3092@nunki.usc.edu> Distribution: usa Organization: The Portal System (TM) Lines: 20 In <3092@nunki.usc.edu>, jeenglis@nunki.usc.edu (Joe English) writes: >Since in 'large' >model all arrays have to fit in the same segment, any >two pointers calculated from the base of the array can >be compared just by their offsets. In normal usage, >this isn't a problem; however, it is possible for two >pointers into *different* arrays to test equal Not true. I just tried it. The <, <=, >= and > comparisons use only the offset parts of the pointers, but == looks at both segment and offset when pointers are 32 bits. This is also documented in the manual (User's Guide v2.0, p.346). It is possible however to have two pointers point to the same storage location but which compare unequal. A one-to-one mapping between pointers and storage locations is not required. Not only is it true that pointers are not ints, they don't even behave like ints. Kevin McCarty