This program is stated to be neither a valid C program nor an invalid C one. But, to my understanding, it can't even be a program which is defined to be a sequence of instructions for the processing unit to compute.
The code is:
That's it. The author alleges:
Some C compilers will compile an empty file into a program that does nothing. But even if your compiler can't, the build instructions supplied with this entry will produce an executable file. On most systems, the stdout from the executable will exactly match original source.
I don't buy it. The compilation will succeed, yielding no instructions. However, the linking will fail as there is no main
symbol to call. If it could be run, then the trick would work because it would output nothing and the source code actually contains nothing.
So, how could (literally, and in which environment) this program
be considered a valid self reproducing program?
Note: it has been accepted as such by IOCCC.
Note this important line:
But even if your compiler can't, the build instructions supplied with this entry will produce an executable file.
See the makefile for the actual build instructions:
smr: smr.c
@${RM} -rf smr
${CP} smr.c smr
${CHMOD} +x smr
Put simply, this actually just creates an empty file with the executable bit set, which will, of course, do nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With