Array bounds checking with C????
Larry Campbell
campbell at redsox.bsw.com
Tue Sep 4 12:33:10 AEST 1990
Are there actually any current compilers out there that are so stupid that
they generate substantially different code for the following two code fragments?
/* Fragment 1 */
for (p = array; p < &array[ARRAY_SIZE]; p++)
*p++ = '\0';
/* Fragment 2 */
for (i = 0; i < ARRAY_SIZE; i++)
array[i] = '\0';
If the answer to my question is "no", then the only excuse for permitting
array indices past the end of an array is for compiling old, crufty code
from clay tablets.
If the answer to my question is "yes", then I think we should flame the
culpable compiler vendors to a crisp.
(hmmm, just tried this on SysV/386, and I guess I have to send a flame to
AT&T... sigh...)
--
Larry Campbell The Boston Software Works, Inc.
campbell at redsox.bsw.com 120 Fulton Street
wjh12!redsox!campbell Boston, MA 02109
More information about the Comp.lang.c
mailing list