Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!mit-eddie!uw-beaver!sumax!polari!rwing!seaeast!burklabs!ronb From: ronb@burklabs (Ron Burk ) Newsgroups: comp.lang.c++ Subject: Portability of pointer comparisons. Message-ID: Date: 10 Oct 90 16:44:19 GMT Organization: Burk Labs, Kirkland WA Lines: 16 Suppose you have a pointer P1 to chunk of memory of size L1 bytes. Now, given another pointer, P2, I wish to determine whether P2 points within the block of memory defined by P1 and L1. I understand that simple pointer comparison: if(P2 > P1 && P2 < (P1+L1)) { then P1,L1 contains P2 } is not portable. My question is, does anyone know of any environment in which you cannot code a reasonably efficient inline function to perform this test correctly? I conjecture that the worst case in existence is a large-model program under MS-DOS that would require the pointers to be normalized before they are compared. My goal is to be able to write software that requires this operation by assuming that any individual operating system can supply a simple inline function that gets the job done.