Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site bbnccv.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!bbnccv!keesan From: keesan@bbnccv.UUCP (Morris M. Keesan) Newsgroups: net.lang.c Subject: Re: 2nd Annual Obfuscated Contest Winners Message-ID: <36@bbnccv.UUCP> Date: Tue, 25-Jun-85 12:03:12 EDT Article-I.D.: bbnccv.36 Posted: Tue Jun 25 12:03:12 1985 Date-Received: Wed, 26-Jun-85 07:10:01 EDT References: <2902@nsc.UUCP> Reply-To: keesan@bbnccv.UUCP (Morris M. Keesan) Distribution: net Organization: Bolt Beranek and Newman, Cambridge, MA Lines: 40 Keywords: precedence Summary: Winner #1 is an illegal progam 1. The most obscure program: (submitted by Lennart Augustsson) is not legal C, even though the 4.2BSD compiler (and presumably other PCC-based compilers) processes it as the author apparently intended. Specifically, the expression > putchar(b?main(b/2),-b%2+'0':10) is illegal. My compiler (BBN C/70 C compiler, based on the Dennis Ritchie PDP-11 C compiler from V7 UNIX) issues the error message "Illegal conditional". A little examination reveals that the error reduces to expr ? expr , expr : expr which is illegal because the comma operator has lower precedence than the conditional operator. See the first paragraph of section 7 of the C Reference Manual (page 185 of K&R), or Page 81 of the System V "Programming Guide", or Sections C.3 and C.3.17 of the April 30, 1985 draft ANSI spec. To make this legal, it must be expr ? (expr , expr) : expr or putchar(b?(main(b/2),-b%2+'0'):10) ------------------------------------------------------------------------- The program further violates K&R C (although it is legal according to all versions I've seen of the proposed ANSI spec, and also according to the System V documentation) by using structure member names non-uniquely; i.e. the structure member a is used both as an int and as a function pointer, and b is used as an int and as a structure pointer [ K&R p. 197: ". . . the same member may appear in two different structures if it has the same type in both . . ." ]. V7 C compilers blow up on this, complaining of redeclaration of a and b. For these two reasons, especially the first, I don't think this program deserves a prize. Also, this is a bug in the 4.2BSD compiler, and even more so in the 4.2BSD lint, which should issue a warning even if the compiler is being forgiving. -- Morris M. Keesan keesan@bbn-unix.ARPA {decvax,ihnp4,etc.}!bbncca!keesan