Hacker News new | comments | show | ask | jobs | submit login

> Undefined behavior is the result of a design decision: the refusal to systematically trap program errors at one particular level of a system.

Huh? This is quite a bit of a false dichotomy... Illegal operations could also result in unspecified behaviour (e.g. it's not specified what result an integer overflow gives, but the rest of the program must continue normally).

> unsafety of machine code

In what way is the machine code unsafe? AFAIK the CPU will always try to execute the code, the worst that can happen is some kind of a trap.




I'm not sure I understand you. What is the difference between undefined and unspecified behavior?

If it was decided that an overflow would generate an error, than it was a design decision to trap errors at that level. The program could crash so that everybody knows something is wrong.

If it was decided that an overflow just would overflow, than it sounds like a refusal to trap the error. The program could continue in an unexpected state.

Maybe it's better to crash the program so you know something is wrong.


> I'm not sure I understand you. What is the difference between undefined and unspecified behavior?

They explained in the very next sentence: "e.g. it's not specified what result an integer overflow gives, but the rest of the program must continue normally".

(In the C standard, "unspecified" is an explicit marker for things where a compiler must document its choice of semantics.)




Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: