Xref: utzoo comp.std.c:877 comp.lang.c:16799 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.std.c,comp.lang.c Subject: Re: detecting invalid pointers Message-ID: <37225@think.UUCP> Date: 8 Mar 89 17:50:16 GMT References: <15495@cup.portal.com> Sender: news@think.UUCP Reply-To: barmar@brigit.think.com.UUCP (Barry Margolin) Distribution: usa Organization: Thinking Machines Corporation, Cambridge, MA Lines: 16 I don't think it is possible to do what you want. C only defines the result of pointer less-than and greater-than comparisons when the pointers are to the same array. It's easy to imagine an implementation where A < P && P < A+N, yet P is not a pointer into the array A[N]. If the system is segmented, and arrays are required to fit within a single segment, the comparison operations might only compare the offset portion of a pointer. If A were at seg1:100, N were 100, and P were seg2:150, the comparison would be implemented as 100 < 150 && 150 < 200. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar