logoalt Hacker News

paparulo329yesterday at 6:59 PM1 replyview on HN

The mere concept of undefined behavior is hilarious to me. "Oh this part? No we can't and won't even try figuring out what doing that does, this page intentionally left blank; yes we are a very serious whole ass standards body thanks for asking"


Replies

layer8yesterday at 10:56 PM

The purpose is to free optimizers from solving the halting problem (and similar undecidable propositions), which they can’t. So the approach is to reduce the allowable programs to those that optimizers can reliably reason about. By the very nature of the problem, these programs cannot in general be distinguished by an algorithm, because again that would require solving the halting problem. So the non-allowable programs are simply declared to be out-of-scope (aka UB).

It’s a controversial trade-off to be sure, but it’s not like there isn’t a sound logic to it.