> it must not be reachable as that's the only way for it to be a legal C program, and then deleted the dead code.
Rather it would make more sense if the approach was more like "this branch is UB so I can whatever is most convenient in terms of optimization" in this case it was merging the 2 branches but discarding the code for the UB branch.
But from a behavioral point of view all these formulations describe the same result
I was referring to this.
IIRC the spec language is that the compiler is free to assume that UB never happens, but from an operational perspective I believe that the compiler simply stop caring about those cases.
by this I mean that for code like
#include <stdio.h>
int main() {
printf("Hello, ");
0/0;
*(NULL);
printf("World!\n");
return 0;
}
most compiler will just pretend that bad lines did not existshttps://godbolt.org/#z:OYLghAFBqd5TKALEBjA9gEwKYFFMCWALugE4A...
> > The core concept is that the compiler assumes the program is valid
I believe that it is more correct to say that the compiler is unrestricted in what it does with UB, so it handles it in the most convenient way (often toward optimizing binary size, runtime performance, and/or compilation time)
By reductio ad absurdum assuming that the program is valid would give the same behaviour. I just believe that it is not what happens operatively.