how has C bitten you?

Jim Moore jmoore at mips.UUCP
Wed Aug 14 02:21:09 AEST 1985


> 
> 	Here's one that just got me:
> 
> 		if (sv > score);   <----- note extraneous semi-colon
> 			score = sv;
>	....
> -- 
> Roy Smith <allegra!phri!roy>
> System Administrator, Public Health Research Institute
> 455 First Avenue, New York, NY 10016

I have seen this bug many times, especially in code written by people
who routinely switch programming languages. It does seem that the compiler
should warn that that test is a no-operation. The problem in general is
that there are 2 copies of the same information: the control flow of 
the program. The compilers copy is contained strictly in the syntax
of the program, while the programmers copy is more loosely defined by
program layout conventions. It is strictly up to the programmer to keep
the 2 copies in sync in some situations. 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.

Jim Moore
MIPS Computer Systems
Mountain View, Ca	[ucbvax | decvax]!decwrl!mips!jmoore



More information about the Comp.lang.c mailing list