3 ms·
It isn't so much that it is unintuitive, for the most part[1], but rather that there are a lot of things to keep track of, and a seemingly innocous change in on
by thayne 2y ago
It isn't so much that it is unintuitive, for the most part[1], but rather that there are a lot of things to keep track of, and a seemingly innocous change in one part of the program can potentially result in UB in somewhere far away. And usually such bugs are not code that is blatantly undefined behavior, but rather code that is well defined most of the time, but in some edge case can trigger undefined behavior.
It would help if there was better tooling for finding places that could result in UB.
[1]: although some of them can be a little surprising, like the fact that overflow is defined for unsigned types but not signed types
- atiedebee 2y agoI think the reason that signed integer overflow is undefined is that it wasn't uncommon at the time to have architectures that didn't represent signed integers with 2's complement. Even today you may find issues with signed integers. The ESP32 vector extensions seem to saturate signed integer overflow [1]. [1]: https://bitbanksoftware.blogspot.com/2024/01/surprise-esp32-s3-has-few-simd.html https://bitbanksoftware.blogspot.com/2024/01/surprise-esp32-...