3 ms·
I think in most cases, people writing code to check for overflow do know whether the system they're on stores integers as twos complement, and they'll have a pr
by to3m 12y ago
I think in most cases, people writing code to check for overflow do know whether the system they're on stores integers as twos complement, and they'll have a pretty good idea what will happen when overflow occurs. A portable approach for this sort of thing would be very useful, but in the mean time, perhaps we could settle for compilers that don't strip out reasonable code?
I know, I know - I'm asking a lot.
My favourite two links on the subject: http://blog.metaobject.com/2014/04/cc-osmartass.html http://blog.metaobject.com/2014/04/cc-osmartass.html, http://robertoconcerto.blogspot.co.uk/2010/10/strict-aliasing.html http://robertoconcerto.blogspot.co.uk/2010/10/strict-aliasin...
- heinrich5991 12y agoThe good thing is that this allows to optimize out in reasonable places too.