3 ms·
> which indicates the undefined behavior actually helps rather than hurts when used with good tooling No, one doesn't need undefined behavior for that at all (
by ojeda 6mo ago
> which indicates the undefined behavior actually helps rather than hurts when used with good tooling
No, one doesn't need undefined behavior for that at all (which does hurt).
What actually helps is diagnosing the issue, just like one can diagnose the unsigned case just fine (which is not UB).
Instead, for this sort of thing, C could have "Erroneous Behavior", like Rust has (C++ also added it, recently).
Of course, existing ambiguous C code will remain to be tricky. What matters, after all, is having ways to express what we are expecting in the source code, so that a reader (whether tooling, humans or LLMs) can rely on that.
- uecker 6mo agoOne doesn't need the undefined behavior and this is not what I said, and one could make it erroneous behavior. But with mainstream compilers being able to trap or wrap, it would be no practical difference except in marketing.