News for hackers. Stuff that matters.
Re:Undefined behavior in C is a reading error by fiter on Thursday May 20, 2021 @05:09PM (#27227290)
This quote is the topic of the original article and the article goes into detail about how it believes the quote should be interpreted.
Re:Undefined behavior in C is a reading error by MauranKilom on Thursday May 20, 2021 @05:38PM (#27227667)
...and yet the article completely ignores the "with unpredictable results" part and instead spends a lot of time discussing all the other valid consequences (which are also only mentioned as examples, at least in the common understanding of "from ... to ...").

Downthread commenters go into more detail regarding the "ignoring e.g. the possibility of signed overflow may mean to assume that it never happens" reading, so I won't elaborate on it here.

Re:Undefined behavior in C is a reading error by vyodaiken on Thursday May 20, 2021 @09:52PM (#27229669)
Leaving overflow to the processor is an example of ignoring it with unpredictable results. Deleting overflow checks because you assume, incorrectly, that overflow is impossible is not an example of ignoring with unpredictable effects, it does produce unpredictable effects, though.
Re:Undefined behavior in C is a reading error by d110af5ccf on Thursday May 20, 2021 @11:09PM (#27230060)
How is the compiler supposed to know that a particular operation is intended as an overflow check though? It isn't a human and it doesn't actually comprehend the code it operates on. It just blindly applies rules.

I want the compiler to eliminate redundant operations. That's a large part of the point of doing optimizations in my view! Best effort attempts to avoid eliminating obvious sanity checks are desired of course, but I doubt it's feasible to reliably identify those short of AGI. (And at that point, why are you still writing code?)

Re:Undefined behavior in C is a reading error by vyodaiken on Friday May 21, 2021 @06:34AM (#27232354)
You are advocating incorrect code that uses a few less machine operations than correct code.
Re:Undefined behavior in C is a reading error by vyodaiken on Friday May 21, 2021 @09:09AM (#27233535)
The compiler should have valid rules, not invalid ones.
Re:Undefined behavior in C is a reading error by _Nat_ on Thursday May 20, 2021 @06:18PM (#27228126)
The original article's interpretation seemed untenable.

While the difference between "Permissible" and "Possible" could be quite significant, in this case, it was qualifying:

> [Permissible/Possible] undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message).

The previously-"Permissible" behaviors were so broad that they basically allowed anything, including translating the source-code in any documented manner.. which basically means that, as long as a compiler says how it'll treat undefined-behavior, it can do it that way, because it's free to completely reinterpret the source-code in any (documented) manner.