Bounds checks. (was variable-length struct hack)

Richard H. Gumpertz rhg at cpsolv.UUCP
Wed Dec 13 01:06:39 AEST 1989


In article <1989Dec11.181631.3864 at jarvis.csri.toronto.edu> norvell at csri.toronto.edu (Theo Norvell) writes:
>		    int A[N], *p;
>		    for(p=A; p < A+N ; ++p ) { ... } /* Good */
>		    for(p=A; p <  &A[N] ; ++p ) { ... } /* Undefined! */

Gee, that is kind of interesting.  Is the result of &A[N] "used as an
operand of the unary * operator" (which is prohibited in 3.3.6)?  That
is, does the & operator cancel out the * implicit in [...]?  I think some
special language might be required in 3.3.6 to allow &* without
undefined results, since this is probably what the committee desired
anyway.  It would be silly to allow A+N but not &A[N]!

-- 
===============================================================================
| Richard H. Gumpertz rhg%cpsolv at uunet.uu.NET -or- ...uunet!amgraf!cpsolv!rhg |
| Computer Problem Solving, 8905 Mohawk Lane, Leawood, Kansas 66206-1749      |
===============================================================================



More information about the Comp.std.c mailing list