Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site uthub.UUCP
Path: utzoo!utcsri!utai!uthub!thomson
From: thomson@uthub.UUCP (Brian Thomson)
Newsgroups: net.lang.c
Subject: Re: 2nd Annual Obfuscated Contest Winners
Message-ID: <217@uthub.UUCP>
Date: Wed, 26-Jun-85 10:23:58 EDT
Article-I.D.: uthub.217
Posted: Wed Jun 26 10:23:58 1985
Date-Received: Wed, 26-Jun-85 11:47:32 EDT
References: <2902@nsc.UUCP>, <36@bbnccv.UUCP>
Organization: CSRG, University of Toronto
Lines: 31
Keywords: precedence

From Morris Keesan (keesan@bbnccv):

>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.

No, I think you're wrong.  The relative precedence of operators exists only
to disambiguate possible parses.  In the example you cite there is only
one valid parse, so precedence doesn't come into it.  The "bug", if you
want to call it that, exists in your compiler rather than in PCC.

PCC-based compilers use a more powerful technique [LALR(1)] for
expression parsing than does the Ritchie compiler [simple precedence, if
I remember rightly], and the simpler technique can't quite hack
the language.
-- 
		    Brian Thomson,	    CSRI Univ. of Toronto
		    {linus,ihnp4,uw-beaver,floyd,utzoo}!utcsrgv!uthub!thomson