3 ms·
When you are in UB it's even more interesting to ask what the hardware actually does because the standard will not specify anything.
by archgoon 7y ago
When you are in UB it's even more interesting to ask what the hardware actually does because the standard will not specify anything.
- saagarjha 7y agoNo, because the compiler will not generate code that is consistent in this case.
- archgoon 7y agoSo? What do you think I'm arguing for here?
- saagarjha 7y agoThere is no standard mapping between "your C code" and "what your computer will do" if your code has undefined behavior. Your compiler will produce some assembly, which you cannot rely on, and that will be "what your hardware does". If that's what you're trying to say I think we agree.
- ralfjung 7y agoThe standard will not specify anything, so what the compiler outputs is gibberish. You are literally looking at a sequence of bytes on which no constraints whatsoever are imposed. LLVM could have compiled my UB program do `0xDEADBEEF` (which I assume is not valid x86 but I do not know) and there would be no compiler bug. Looking at `0xDEADBEEF` here is not useful. Trying to interpret the assembly of a UB program is like trying to interpret the noise of a radio when there is no station on the given frequency. It has more to do with fortune telling than anything else. There is no signal in there, or at least not enough of it to be useful.