For what it's worth, C++ also passes your test here. You picked an example so simple that it's not very interesting.
For what it's worth, C++ also passes your test here. You picked an example so simple that it's not very interesting.
I'm not claiming that C (or C++) is without problems. I wrote code in them for ~20 years and that was more than enough; there's a reason I use Rust for all my new low-level projects. In this case, writing C without undefined behavior requires lots of third-party static analysis tooling that is unnecessary for Rust (due to being built in to the compiler).
But if you're going to be writing C as "portable assembly", then the competition isn't Rust (or Zig, or Fortran), it's actual assembly. And it's silly to object to C having undefined behavior for signed integer addition, when the alternative is to write your VM loop (or whatever) five or six times in platform-specific assembly.
Your original comment didn't specify that you want to talk about unsigned integers only.
I don't think the standard says much about how to handle stack overflows?