2nd Annual Obfuscated Contest Winners

Lennart Augustsson augustss at chalmers.UUCP
Sat Jun 29 08:50:28 AEST 1985


[I really shouldn't spend more time on these silly programs.]

In article <36 at bbnccv.UUCP> keesan at bbnccv.UUCP (Morris M. Keesan) writes:
>1. The most obscure program:
>(submitted by Lennart Augustsson <seismo!mcvax!enea!chalmers!augustss> )
>
>is not legal C, even though the 4.2BSD compiler (and presumably other PCC-based
>compilers) processes it as the author apparently intended.
....
>A little examination reveals that the error reduces to
>
>    expr ? expr , expr : expr
>
I actually didn't think it would work, but I tested removing the parenthesis
around the (expr,expr) and it still worked!  So, since the purpose was to
produce an obscure program I kept them removed (another reason was that
the program was a bit to long at that moment).

>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.
Since this seems to be an accepted extension to C I don't think it requires
any defense.

BTW, the program contains another non-portable construction: b / 2 where
b is negative, this may cause problems on some machines.

-- 
Any resemblance of the opinions above to real opinions, living or dead,
is purely coincidential.
	Lennart Augustsson
UUCP:		{seismo,philabs,decvax}!mcvax!enea!chalmers!augustss
ARPA,CSnet:	augustss at chalmers.csnet



More information about the Comp.lang.c mailing list