detecting invalid pointers

RAMontante bobmon at iuvax.cs.indiana.edu
Sun Mar 12 04:08:13 AEST 1989


bill at twwells.UUCP (T. William Wells) <767 at twwells.uucp> :
-In article <3011 at nunki.usc.edu> jeenglis at nunki.usc.edu (Joe English) writes:
-: Take, for example, the (you guessed it) 80x86 series in
-: 'large' model, where pointers aren't normalized.  It's
-: then possible for two pointers to point to the same location
-: yet have different segment:offset pair values.  Most '86 compilers
-: will *not* get this comparison right, since pointers are in general
-: not normalized before comparisons to save time and space.
-
-In which case, the compiler is broken. But we knew that...?


Hmm, this leads me to a question.  I think I understand that pANS requires a
valid comparison of pointers that refer to the same object (esp. array).
But does the compiler or run-time code need to KNOW that the pointers are to
the same object for this to hold?  Or is it sufficient that the pointers
refer to memory that is somehow associated (by malloc'ing perhaps)?

To put it another way -- If I get tricky enough with indirection, casting,
etc. (but I only do legal things), is it possible/legal to wind up with a
pointer comparison that is NOT guaranteed to produce a "correct" answer
within the bounds of pANS?

Vacationing minds hope the answer will be here when I get back....



More information about the Comp.lang.c mailing list