Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When you are in UB it's even more interesting to ask what the hardware actually does because the standard will not specify anything.


The 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.


No, because the compiler will not generate code that is consistent in this case.


So? What do you think I'm arguing for here?


There 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: