Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site kitty.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rochester!rocksanne!sunybcs!kitty!peter From: peter@kitty.UUCP (Peter DaSilva) Newsgroups: net.lang.c Subject: Re: how has C bitten you? Message-ID: <207@kitty.UUCP> Date: Thu, 1-Aug-85 10:18:39 EDT Article-I.D.: kitty.207 Posted: Thu Aug 1 10:18:39 1985 Date-Received: Sat, 3-Aug-85 05:53:39 EDT References: <4051@alice.UUCP> Organization: Recognition Research Corp., Clarence, NY Lines: 17 > I am collecting examples of how C can bite the unwary user. > > Consider, for example, the following program fragment: > > int i, a[10]; > for (i = 0; i <= 10; i++) > a[i] = 0; > > On many implementations, this will result in an infinite loop. I assume you mean that auto's are allocated on the stack so &a[10]==&i. I don't see an easy solution to this, except for built-in range checking. I think "Safe/C" has this... Anyone who uses "<=" in a for(;;) loop to initialise an array should be strung up by their index(3) fingers and forced to listen to Sonny Bono chanting "Zero Origin Arrays" until their ears fall off [:->].