Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!alberta!mts.ucs.UAlberta.CA!Al_Dunbar From: userAKDU@mts.ucs.UAlberta.CA (Al Dunbar) Newsgroups: comp.lang.c Subject: Re: Array bounds checking with C???? Message-ID: <1310@mts.ucs.UAlberta.CA> Date: 8 Sep 90 02:45:37 GMT References: <1589@redsox.bsw.com> <1990Sep6.203031.29254@laguna.ccsf.caltech.edu> Organization: MTS Univ of Alberta Lines: 22 In article <1990Sep6.203031.29254@laguna.ccsf.caltech.edu>, jimmy@tybalt.caltech.edu (Jimmy Hu) writes: >In article <1589@redsox.bsw.com> campbell@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'; >> Actually, the first fragment will set every other element of the array to '?0', as the pointer is incremented twice per trip through the loop. -------------------+------------------------------------------- Al Dunbar | Edmonton, Alberta | this space for rent CANADA | -------------------+-------------------------------------------