Re: Compiles without Executing



CNerd2025 wrote:
My boss, sort of an eccentric guy, came in today and asked if I could
write a program that:
a) compiles correctly
b) is logically correct, and
c) never executes.

I immediately told him a seg fault, but he said, "it is entirely
correct". He also mentioned that some guy at (he believes)
Rutherford-Appleton Laboratory has solved it with some 4-line program.
Anyone know what's up with it? Thanks.

--Drew


Was it a test of your knowledge, or has he written a program that crashes before entering main and he's trying to figure out how to debug it?

Personally I'm inclined to answer "no" to the question; if it compiles and is correct, then it will run. If a program is designed to segfault and segfaults, then it is running correctly thus contradicting c. Or I'd skip the daft question and go straight to "why?" and probe for the above possibility.

I doubt someone in RAL has "solved" it with a 4-liner. If it gets past the first line then it is executing and thus contradicts c. If it doesn't get past the first line then he could solve it with a one liner that is a copy of the four liner without the extra three lines; in fact you could "solve" it with any length program; if it doesn't get past the first line then what comes after that is completely irrelevant.

Dave.
.