Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: nasty evil pointers Message-ID: <3124@haddock.ISC.COM> Date: 22 Mar 88 23:55:18 GMT References: <13100003@bucc2> <1159@silver.bacs.indiana.edu> <2315@bsu-cs.UUCP> <338@wsccs.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 18 In article <338@wsccs.UUCP> terry@wsccs.UUCP (terry) writes: >> >It would be nice if we could check every pointer as it was used... >[If necessary you could define a pointer-verifying function, and use] > p = (char *)savemefrommyself( (void *)q); > >Personally, I'd prefer it if the compiler didn't automatically write this for >me. I'd prefer the best of both worlds: make it an option. >Eventually, you'd end up with it breaking something like [assigning NULL] Well, that's because of an imperfection in the verifying function. The value NULL is legal to copy, but illegal to dereference or perform arithmetic on. You need to have two separate verification routines. (It still wouldn't be perfect; the posted function only checked for completely wild pointers. A better implementation would catch array overflow, too.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint