2 ms·
One of the more pernicious problems is security checks written to detect underhanded violations of constraints being eliminated because the compiler doesn't rec
by barrkel 6y ago
One of the more pernicious problems is security checks written to detect underhanded violations of constraints being eliminated because the compiler doesn't recognize the underhandedness is possible.
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.
- sharpneli 6y agoMaking signed overflow to be well defined would be so much better. IIRC C++ just decided that signed numbers are two's complement and that's that. C could really use similar thing.
- steerablesafe 6y ago> IIRC C++ just decided that signed numbers are two's complement and that's that. Signed integer overflow is still undefined in C++.
- sharpneli 6y agoYou are correct. I misremembered, it was just a proposal that was not taken into the spec.
- steerablesafe 6y agoNo, it's taken into the spec. It affects unsigned <-> signed conversions and maybe other things. Not integer overflow though.
- sharpneli 6y agoAh. Makes sense as that’s relatively cheap to emulate by just doing conversion when loading and storing from memory, but allows the use of HW even in case of ones complement implementation.