>>51043231Like, I don't know if you guys have never tried to understand compilers or what.
Suppose we have a language with a signed integer type, and that language says that adding 1 to the maximum positive representation is undefined.
Now consider a compiler for this language encountering
int a = may_never_return();
int b = a+1;
How do you compile the line which adds a and 1? You do a case analysis.
I) A is INT_MAX: adding 1 to INT_MAX is undefined, compiler has no obligations, so don't bother emitting code for this branch
II)A isn't INT_MAX: do the addition like normal
It isn't about solving the halting problem.
Suppose we had a language that didn't have undefined behavior in this case; say, for instance, that addition is always considered to happen as unsigned addition modulo representation size and then were simply interpreted as a two's compliment number. Then when you encounter the line
int b = a+1 your case analysis is different.
I) A is INT_MAX. Do something special maybe depending on the architecture.
II) A isn't INT_MAX. Do the addition like normal.
The halting problem is totally and completely not part of this (except for C++ which cannot even be guaranteed to parse, nevermind compile).