Out-of-bounds pointers

Henry Spencer henry at utzoo.uucp
Sat Oct 7 02:52:46 AEST 1989


In article <12570028 at hpclwjm.HP.COM> walter at hpclwjm.HP.COM (Walter Murray) writes:
>the wording of 3.3.6 might be misleading:  "Unless both the pointer
>operand and the result point to elements of the same array object,
>or the pointer operand points one past the last element of an array
>object and the result points to an element of the same array object,
>the behavior is undefined if the result is used as an operand of
>the unary * operator."  Doesn't this imply rather strongly that it
>IS legal to compute an invalid address, as long as it isn't
>dereferenced?

Read the previous sentence in 3.3.6:  "If both the pointer operand and
the result point to elements of the same array object, or one past the
last element of the array object, the evaluation shall not produce an
overflow; otherwise the behavior is undefined."
-- 
Nature is blind; Man is merely |     Henry Spencer at U of Toronto Zoology
shortsighted (and improving).  | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.std.c mailing list