October 21st, 2024

Smallest Self Reproducing Program

The 1994 IOCCC entry "Worst abuse of the rules" by Szymon Rusinkiewicz claims to be the smallest self-reproducing program, prompting judges to revise contest rules to prevent similar submissions.

Read original articleLink Icon
Smallest Self Reproducing Program

The International Obfuscated C Code Contest (IOCCC) features an entry from 1994 titled "Worst abuse of the rules," authored by Szymon Rusinkiewicz from the United States. This entry claims to be the world's smallest self-reproducing program. The judges noted that while many submissions in previous years claimed similar titles, they often exceeded the expected size. This particular entry, however, is unique as it is not a valid C program in the traditional sense, yet it can be compiled into an executable that outputs its own source code. The judges decided to amend the contest rules to establish a minimum size requirement, preventing similar entries in the future. The author asserts that this program is guaranteed to replicate itself, producing a listing of its own code when executed. The entry includes primary files such as the source code (smr.c), a Makefile, and a script for testing the entry, along with secondary files for distribution and documentation.

- The 1994 entry "Worst abuse of the rules" is by Szymon Rusinkiewicz.

- It claims to be the world's smallest self-reproducing program.

- The judges plan to revise contest rules to prevent similar entries in the future.

- The program can compile into an executable that outputs its own source code.

- The entry includes various files for building and testing the program.

Link Icon 2 comments
By @256_ - 3 months
> While strictly speaking, smr.c is not a valid C program, it is not an invalid C program either! Some C compilers will compile an empty file into a program that does nothing.

How do they define "invalid"? Section 6.7 (page 81) of the C89 standard defines a translation unit as a series of one or more external declarations.

I assumed that a main() function was a requirement, but section 5.1.2.2 (page 6) does not require this (which seems obvious in retrospect; that's how object files are compiled).

I think the shortest valid C program would be "f();". gcc accepts it. In fact, gcc agrees with my conclusion above, and says, for a blank file: "ISO C forbids an empty translation unit".

What do other compilers say?