ANSI C, hardware protection, out-of-bounds pointers

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Sep 7 21:09:42 AEST 1989


In article <867 at hadron.UUCP> jsdy at hadron.UUCP (Joseph S. D. Yao) writes:
>-	char *head=a-1;		/* Here! */
>This, too, is an out-of-bounds pointer, and is covered by the same
>rule.  Nothing says that an OOB ptr has to be positively offset.

Sorry, Joe, but you're wrong.  Only the last+1 OOB pointer is legal,
not the first-1.  I've seen this fail in practice (in AT&T's UNIX
implementation of bsearch(), as I recall) when the array element
was fairly large and first-1 happened to wrap around the address
space.



More information about the Comp.std.c mailing list