Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site mips.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!Glacier!mips!mash From: mash@mips.UUCP (John Mashey) Newsgroups: net.lang.c Subject: Re: how has C bitten you? Message-ID: <167@mips.UUCP> Date: Tue, 13-Aug-85 15:28:41 EDT Article-I.D.: mips.167 Posted: Tue Aug 13 15:28:41 1985 Date-Received: Sat, 17-Aug-85 16:29:10 EDT References: <302@brl-tgr.ARPA> <4081@alice.UUCP> <243@ecrhub.UUCP> <123@ecsvax.UUCP> <389@phri.UUCP> <166@mips.UUCP> Distribution: net Organization: MIPS Computer Systems, Mountain View, CA Lines: 40 > > Here's one that just got me: > > > > if (sv > score); <----- note extraneous semi-colon > > score = sv; > I have seen this bug many times, especially in code written by people > who routinely switch programming languages.... There was a paper given at a > USENIX (Toronto?) describing an experiment with different program layout > techniques. The programs were written without any explicit grouping brackets, > and were specified by the layout and indentation. A program filter would > add all the required brackets and buzzard wings before feeding it to the > compiler. As I recall, there was a related bug in MERT, way back, of the form: if (something) stmt1; stmt2; stmt3; where the the {}'s were "invisible". The one I always remember most of the C bites was the truly infamous bug in chksum in uucp/pk0.c. (This was actually a code bug, masked by bug in VAX compiler and irrelevant on 16-bit machines; it caused almost every 68K port (that used the MIT C compiler, anyway) to break uucp, in that the 68Ks could talk to each other, but not to VAXEn or 16-bit machines). The bug was in lines of code that looked like: short s; unsigned short t; ... if ((unsigned) s <= t) ... where they really meant if ((unsigned short)s <= t). The VAX did (incorrectly) a 16-bit compare, rather than all of the correct conversions. I'd call this a C bite, simply because psychologically, it "feels" like (unsigned) type should mean (unsigned type) type, although it clearly does not. -- -john mashey UUCP: {decvax,ucbvax,ihnp4}!decwrl!mips!mash DDD: 415-960-1200 USPS: MIPS Computer Systems, 1330 Charleston Rd, Mtn View, CA 94043