Hacker News new | ask | show | jobs
by tzs 594 days ago
I remember someone quipped that every program always has at least one bug left, and every program could be optimized to be smaller.

It follows then that with a sufficiently good optimizer every program can be reduced to a single wrong instruction.

2 comments

    /* Optimize a program.
       May perform unsafe optimizations.
       May introduce up to 1 bug.
     */
    char *optimize(char *program) {
        (void) program;
        return ".export main\nmain:\n\tub2\n";
    }
That’s golden!

Can even make it half the size with an instruction that is invalid in 64bit mode, maybe such as INTO

And that instruction can be removed too: zero byte ".text" section -> page fault
Once, when a bunch of us were sitting in my office trading debugging[0] war stories, the owner of the company dropped in[1], figured out the convo, and interjected:

"That's nothing; I once wrote a single line of assembly that had 3 bugs."

then left...

[0] we'd gotten to the subject because I was in the midst of using an oscope to decide if my ROM monitor or my libc or both were buggy.

[1] perhaps to discover why all the other offices were vacant?