ANSI C, hardware protection, out-of-bounds pointers
Joseph S. D. Yao
jsdy at hadron.UUCP
Thu Sep 7 13:45:27 AEST 1989
In article <427 at maytag.waterloo.edu> lhf at aries5 (Luiz H. deFigueiredo) writes:
-ANSI C says that is *is* legal to use mention (but not dereference) a pointer
-just out-of-bounds as in
-
- char a[N];
- char *last=a+N; /* Here! */
- char *p;
- for (p=a; p<last; p++)
-Now I ask, it is possible/legal to do the analogous thing for a-1 as in
- char *head=a-1; /* Here! */
- for (p=last-1; p>head; p--)
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.
joe yao
More information about the Comp.std.c
mailing list