davidsen@steinmetz.ge.com (William E. Davidsen Jr) (09/08/88)
I recently proofread a manual which stated that even calculating the value of an invalid address could cause a memory fault. I read this to mean that code like: int D_temp[30], /* 30 elements */ *tempr = D_temp-100; /* int tempr[100..129] */ would cause a problem even if the pointer were not dereferenced. I would assume that calculating a value would not EVER cause a dereference (and thereby a fault), no matter how invalid the address. An example in point are the machines which will fault if you try to dereference a NULL pointer. Simply having the value NULL doesn't cause a problem. Is there a portion of dpANS which states that this is/isn't allowed, or that it's implementation dependent? Seems like "common practice" to me, and portable, as long as you don't use the pointer other than as a starting point back to the defined array. BTW: the example above is how you convert a Pascal program with a range to C. Access is rangechecked by a macro package. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me