TBH that doesn’t sound like we are mostly on the same page.
I think UB meaning “anything can happen” is a reasonable approach, you just need a precise definition of which conditions lead to UB. Also see my blog post on the topic.
Do you mean this one? I don’t think I did, thanks for the pointer! I’ll read it more carefully later. I think I have seen it before but clearly I need to re-read it, then.
If by “guaranteed by the implementation” he means “the current implementation happens to do this”, then I find myself very strongly disagreeing with Linus.
If he means “the documentation says that this is and always will be guaranteed”, then sure, relying on it is fine. At that point you are writing “GCC C” instead of “ISO C”, but there is nothing inherently wrong with that (as long as you don’t intend to ever switch compilers…).
I do agree with this one. Rust’s approach to integer overflow is a good example for this.
That said, sometimes I think we should also have unsafe integer arithmetic operations that actually do assume to be non-overflowing, because there are some cases where that can help the optimizer a lot. In a language as relying on the optimizer as Rust, having a good interface for the programmer to communicate assumptions to the optimizer is crucial. Making such assumptions the default for all arithmetic is indeed “flat-out insane”—but just having such an interface means you need to say things like “violating these assumptions is UB”, and that UB must be of the form “literally anything may happen” (aka "you just assumed false" in logic), otherwise it is not useful.
So maybe we actually agree more than I thought: many cases of UB in C++ ought to not allow anything to happen. But then instead of weakening what programs with UB can do, I’d just not call these UB any more (but “relying on implementation-specific behavior”, or so)—because we also do need a kind of UB that does allow anything to happen, and “UB” is how the entire world calls that, so I’d say let’s stick to that terminology.
In Rust IMO saner choices were made wrt. what is and is not UB, so for the things that are UB, we really do want “anything can happen”-style UB.