Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!td From: td@alice.UUCP (Tom Duff) Newsgroups: net.lang.c Subject: Self-reproducing C programs Message-ID: <2988@alice.UUCP> Date: Tue, 18-Sep-84 17:12:06 EDT Article-I.D.: alice.2988 Posted: Tue Sep 18 17:12:06 1984 Date-Received: Tue, 25-Sep-84 03:26:35 EDT Organization: AT&T Bell Laboratories, Murray Hill Lines: 16 It is possible to generate (syntactically invalid) C programs whose error message output from cc is identical to the program input. An easy way is to use the following shell script: echo hi >x echo bye >junk.c until cmp -s x junk.c do mv x junk.c cc junk.c 2>x done When this terminates, it will have found a fixed-point of the cc command. I won't reproduce the output here. It varies from compiler to compiler, and can be more than a hundred lines long. Thanks to Dennis Ritchie and Rob Pike for suggesting this approach.