Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: -fstrict-overflow and -Wstrict-overflow



On Sat, Oct 13, 2012 at 11:42:42AM +0200, Alan Barrett wrote:
> 
> However, I think that -fstrict-overflow (implied by -O2) is fine; 
> it permits optimisations that may surprise people who forget that 
> signed integer overflow is undefined, but such optimisations are 
> allowed by the language.

I've been caught out on systems where signed integer arithmetic saturates
(or rather does depending on a cpu flag).
Rather made a mess of some counters!

At least saturating is better than discarding the result (which is what
at least 1 COBOL system did) - very difficult to spot something is wrong
when you add a list of numbers that doesn't quite fit.

A big fubar is that modulo arithmetic often needs signed comparisons,
which requires a cast after the subtract.

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index