by fortran77 · 6y ago · 0 comments
In a past life, I depended on signed overflow to detect out of bounds memory allocations. That kind of stuff gets compiled away these days, you need to be cleverer to detect when the user is deliberately trying to invoke UB. And because the compiler doesn't believe in UB, there's the risk it's going to remove your detection logic.
IIRC C++ just decided that signed numbers are two's complement and that's that. C could really use similar thing.
Signed integer overflow is still undefined in C++.
Quoting from the abstract of that talk: "... preserving source-level dependencies through to the generated CPU instructions is achieved through a delicate balance of volatile casts, magic compiler flags and sheer luck. Wouldn't it be nice if we could do better?"
In my years of working with C its always the 'look how smart I am code' causes issues.
Keep it clean and simple. Avoid complexity and fluff features of C. And you will not going to have deal with exotic bugs.