Conversation

Also, signed overflow being undefined rather than defined as wrapping means that more secure implementations where it traps are permitted. Passing -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow is standards compliant and used for hardening in AOSP.
3
5
That code can be fixed and the fixes are clear cut bug fixes. High quality C code is tested with ASan, TSan, UBSan, etc. and many of these issues are already being caught and fixed over time. Portable and safe C code needs to avoid relying on undefined behavior like this.
2
5
C isn't defined as that language, and you're not in a position where you get to define the language. In the real world, C is deployed with various safety features taking advantage of many things being undefined and reducing portability / compatibility with those wouldn't be good.
2
5
Neither of us gets to choose how C is defined. You want to make it more permissive, and I would make it stricter and safer. Instead, the standard compromises between all the competing interests (portability, performance, safety) by giving implementations lots of freedom.
2
Okay, and that's not how C is defined or how it's likely to ever be defined. You're free to make a standard for your own language based on C. I don't think what the world needs is a memory and type unsafe language that's even more permissive, but you're free to make one.
1
Yes, it does make it more permissive. You want to forbid implementations of C that trap on out-of-bounds accesses, signed overflow, etc. which is currently permitted by the standard and widely deployed in production systems in the real world to improve safety and security.
2