Array bounds checking with C????
Interplanetary Krill
mikey at ontek.com
Thu Sep 6 09:12:03 AEST 1990
In comp.lang.c, campbell at redsox.bsw.com (Larry Campbell) writes:
| 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';
Fragment 2 is superior in that it initializes the entire
array rather than just elements with even numbered indexes.
__
/x \/|
\__/\|
More information about the Comp.lang.c
mailing list