"gooch" <> writes:
> You can index up to whatever value you want. p[1000] is fine. The
> result is going to be undefined. In most cases you would get a seg
> fault but that may not be the case. You have to do the bounds checking
> yourself.
(I presume p is an array with fewer than 1001 elements.)
p[1000] is not "fine" in any sense of the word. It is a serious error
that the implementation is not required to diagnose. This can
sometimes have the same visible results as something that's perfectly
legal, but the distinction is critical.
Incidentally, it's not true that "in most cases you would get a seg
fault". Attempting to access an array beyond its bounds is very
likely to refer to some other variable in your program, with
unpredictable results.
Your overall point, that you have to do your own bounds checking
because the implementation won't do it for you, is quite correct; I'm
just (over)reacting to your use of the word "fine".
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.