Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!ateng!chip From: chip@ateng.ateng.com (Chip Salzenberg) Newsgroups: comp.lang.c Subject: Re: detecting invalid pointers Message-ID: <1989Mar21.085704.15894@ateng.ateng.com> Date: 21 Mar 89 13:57:03 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: A T Engineering, Tampa, FL Lines: 25 According to jeenglis@nunki.usc.edu (Joe English), referring to normalizing 80x86 segment+offset pointers before comparing them: >Turbo C (and probably MSC as well) don't bother to most of the time. [...] Quite true. For totally correct comparisons of all pointers, it's necessary to normalize them by hand, or be sure that they are cast to "huge *" when any pointer arithmetic is done. Otherwise, the different combinations of segment+offset that actually refer to the same address do not compare equal. >it is possible for two pointers into *different* arrays to test equal [...] Fortunately, this is false. Comparisons of *magnitude* only examine the offset -- which is OK. Comparisons of *equality* examine both the segment and offset -- otherwise, any pointer with an offset of zero would compare equal to NULL. For understanding compiler options and non-standard keywords, there's no substitute for looking at the assembler output of a compiler. Yes, the documentation is the definitive guide, but looking at the assembler output is a wonderful aid in understanding what the documentation means. :-) -- Chip Salzenberg or A T Engineering Me? Speak for my company? Surely you jest! "It's no good. They're tapping the lines."