Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could this program be meaningful?

Tags:

c

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.

like image 877
edmz Avatar asked Dec 20 '22 07:12

edmz


1 Answers

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.

like image 127
Alexis King Avatar answered Jan 16 '23 15:01

Alexis King