Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!twwells!bill From: bill@twwells.com (T. William Wells) Newsgroups: comp.lang.c Subject: Re: Pointer arithmetic and comparisons. Message-ID: <1989Dec11.081346.8553@twwells.com> Date: 11 Dec 89 08:13:46 GMT References: <257ECDFD.CDD@marob.masa.com> <232@bohra.cpg.oz> Organization: None, Ft. Lauderdale, FL Lines: 18 In article <232@bohra.cpg.oz> ejp@bohra.UUCP (Esmond Pitt) writes: : That's because the last element is not &buffer[last] but &buffer[last-1], : and so you should test for <= &buffer[last-1], not < &buffer[last]. : You are incrementing a pointer to point outside the object, and this is : not guaranteed to work under _any_ implementation of C. Not only is this going to work in most implementations, it is *required* to work by the ANSI standard. My guess is that his object is exactly 64K bytes long and he is running into the silly segmentation problems of the 8086. There are two fixes: use an object of no more than 64K-1 bytes or use whatever model it is that does the right thing with objects of size 64K and larger. --- Bill { uunet | novavax | ankh | sunvice } !twwells!bill bill@twwells.com