[personal profile] sassa_nf
char isEven(unsigned int n);
  
char isOdd(unsigned int n) {
   return n && isEven(n+1);
}

char isEven(unsigned int n) {
   return isOdd(n+1);
}

int main(int argc, char** argv) {
   printf("%d %d\n", argc, isEven(argc));
   return 0;
}

This program decides all integers are not even, if compiled with gcc -O2.

The cause of this is that both isOdd and isEven were replaced by a constant 0. Apparently, because http://eel.is/c++draft/intro.progress allows the compiler to assume that isOdd can only return 0, without proving that it terminates.

Basically, if it terminates, then it can only return through "n && ..." evaluating to 0. But now it is ok to assume it always returns 0 - because that's the only way it could have terminated.


All it took to solve Entscheidungsproblem, was a committee of clever engineers: all C programs terminate. Give Gödel some slack! He couldn't have known that, could he?
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

sassa_nf

January 2026

S M T W T F S
    123
45678910
111213141516 17
18192021222324
25262728293031

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 21st, 2026 01:32 am
Powered by Dreamwidth Studios