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

There's nothing wrong with undefined behaviour.


Undefined behavior means the language provides no guarantees about the outcome. Whatever happens is up to the compiler, or rather the specific implementation of the compiler, and the target architecture on which the program is run. These things are not constrained by any spec or guarantee, so they are allowed to change, for any reason, to anything. These changes may be triggered by not only different execution environments, but also changes to properties of a given execution environment. The behavior of a program with undefined behavior is non-deterministic, and cannot be predicted, modeled, or effectively maintained.


> Undefined behavior means the language provides no guarantees about the outcome.

No, not "the language", but "the standard".

Languages like Python or Rust that don't have standards are 100 percent undefined behavior.

If you're really worried about this, then just code against x86_64 clang and not ISO C++ and forget about this non-problem forever.


s/language/language as defined by the specification that also defines the concept of undefined behavior/


Like I said, Rust and Python have no specification at all, so technically any program written in them is undefined behavior, depending on the particular interpreter/compiler binaries you use and your architecture.


undefined behavior is not the absence of a spec, it's a specific condition that specs define




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

Search: