Reducing undefined behavior in the C language

lwn.net

49 points by signa11 3 hours ago


chasil - 2 hours ago

"Some Honeywell machines, for example, had nine-bit bytes."

OS 2200 has 36-bit words. It is still a supported platform.

https://en.wikipedia.org/wiki/UNIVAC_1100/2200_series

This platform was the first SMP UNIX implementation:

"Any configuration supplied by Sperry, including multiprocessor ones, can run the UNIX system."

https://www.nokia.com/bell-labs/about/dennis-m-ritchie/other...

1vuio0pswjnm7 - an hour ago

1790620504 | Reducing undefined behavior in the C language | https://lwn.net/SubscriberLink/1095811/b9325731ea9b61e0/ | https://news.ycombinator.com/item?id=49882419 | 15 comments

1790673092 | Reducing undefined behavior in the C language | https://lwn.net/SubscriberLink/1095811/efcdbcf080cfa4c6/ | https://news.ycombinator.com/item?id=49890290 | 0 comments

elais-dev - 2 hours ago

i've seen static analyzers catch many ub patterns, but guaranteeing zero ub needs whole‑program analysis that blows up compile time and still produces false positives that drown developers

BeaverGoose - 2 hours ago

Make signed overflow defined please.

p1necone - 2 hours ago

The concept of undefined behaviour specific to C/C++ has always seemed batshit insane to me, and I'm yet to read anything about it that has made it seem any less so.

jdw64 - 2 hours ago

[dead]

jdw64 - 2 hours ago

If we follow this video, the real constraints essentially mean POSIX and ABI. This implies that the contract a programmer must understand is distributed across multiple layers—not just the language specification, but effectively the operating system and ABI as well. Ultimately, this leads to the conclusion that even if the language itself is fundamentally free, constraints are inherently necessary at its lower layers. If we were to bloat the compiler—that is, if we restricted freedom like Rust does with its borrow checker—then the freedom available to the programmer would vanish. If that happens, people might grow weary of a language that is supposed to be free. In the end, any single layer inherently restricts freedom. In other words, I feel there is a need to transfer the complexity that a programmer must manage over to a mechanical management system, but which layer would be best for that?

Currently, based on experience, this level of complexity is categorized into the language layer, and that level of complexity into the operating system layer. But in the future, won't there be some sort of complexity theorem that determines which layer minimizes complexity the most, and won't systems be completely rewritten based on that?