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

Last I checked UB was undefined by the standard, but compilers still need to define their behavior on each architecture.

Dictating that all architectures implement UB the same way would have significant overhead, since it would force programs that don’t rely on UB to run in emulation on all but one architecture (at best).



Undefined behavior does not need to be consistent, either across different programs, or within the same program. It does not need to be consistent within different times that the program is run, and it does not need to be documented anywhere. It does not need to be sensible, does not need to be predictable, and does not need to give any diagnostics to warn the programmer. Undefined behavior means that you have passed outside of the realm governed by the standard, and that HERE BE DRAGONS.

Implementation-defined behavior works as you say, where each compiler can define how it responds to certain circumstances.


that's implementation defined




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

Search: