Xref: utzoo comp.std.c:352 comp.lang.c:12393 Path: utzoo!attcan!uunet!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.std.c,comp.lang.c Subject: Invalid pointer addresses Keywords: NULL, pointer Message-ID: <12088@steinmetz.ge.com> Date: 7 Sep 88 20:07:12 GMT Reply-To: davidsen@crdos1.UUCP (bill davidsen) Followup-To: comp.std.c Distribution: na Organization: GE Corp. R & D, Schenectady,NY Lines: 25 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