Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!mimsy!eneevax!noise From: noise@eneevax.UUCP (Johnson Noise) Newsgroups: comp.lang.c Subject: Re: Is this a bug, or is it just me? Message-ID: <1145@eneevax.UUCP> Date: 21 Dec 87 00:46:15 GMT References: <464@ecrcvax.UUCP> <1923@rti.UUCP> Reply-To: noise@eneevax.umd.edu.UUCP (Johnson Noise) Organization: Elec. Eng. Dept., U of Maryland, College Park, MD 20742 Lines: 34 Keywords: Design Philosophy. In article <1923@rti.UUCP> trt@rti.UUCP (Thomas Truscott) writes: >In article <464@ecrcvax.UUCP>, johng@ecrcvax.UUCP (John Gregor) writes: >> sum = a[i++] + a[i++] + a[i++]; > >Gems like this are posted to Usenet every month or so (it seems), >and the usual response is "Poor grasshopper, read K&R page 50 >and stop bothering us". > >I wish the responses would include something like >"Why don't C compilers flag blatant errors such as the above?" >If we all said bad things about compilers that permitted such code >I bet the vendors would fix them! Maybe even AT&T. > >And come to think of it, why doesn't someone fix the 4.3BSD compiler >to do this? After all 4.3BSD "lint" finds it. >Just steal the code from lint! (And catch "i = i++;" too.) > Tom Truscott There is a very good reason why this and other checks caught by lint are not caught by cc: design philosophy. Lint is a C program checker and cc is a C compiler. The two functions are seperated into different utilities so that cc can be made to run fast. According to the UNIX programmer's manual, lint is to be used after a program is written, compiled and tested in order find non-portable and potentially dangerous constructs in the source deck. This design philosophy is meant to be consistent with the UNIX operating system as a whole. In addition, the C programming language is designed and imple- mented with the assumption that the programmer is competent and has an intimate understanding of the subtleties involved. This is done to allow greater flexibility and performance with respect to compilation and code generation, i.e. C is a real language for real men. Other languages, such as Pascal, Modula 2 and Ada, are not des- igned with this philosophy in mind and therefore do not yield the type of performance that C enjoys.