nasty evil pointers

Karl Heuer karl at haddock.ISC.COM
Wed Mar 23 09:55:18 AEST 1988


In article <338 at wsccs.UUCP> terry at 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 at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list