detecting invalid pointers

T. William Wells bill at twwells.uucp
Sun Mar 12 14:05:19 AEST 1989


In article <18460 at iuvax.cs.indiana.edu> bobmon at iuvax.cs.indiana.edu (RAMontante) writes:
: 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?

No. The whole point of sticking with legal things is that, after you
are done, it all still works. So, for as long as each cast is a valid
one, indirection is only done when the pointer is of the right types,
and all the other things that are supposed to be done correctly are
in fact done correctly, one is not supposed to be able to produce an
"incorrect" answer.

---
Bill
{ uunet | novavax } !twwells!bill
(BTW, I'm going to be looking for a new job sometime in the next
few months.  If you know of a good one, do send me e-mail.)



More information about the Comp.lang.c mailing list