Bug#362414: abs() returns a negative number
* Martin Michlmayr <tbm@cyrius.com> [2006-04-14 11:08]:
> > > sum_abs = abs (sum_abs + abs (abs (data [k]) - 256)) ;
> > >
> > Looks like you are working near limits of 'int' type, and different
> > valid optimizations could change order of calculation, either
> > causing data overflow or not. Try using long long instead of int.
>
> Just changing sum_abs to long doesn't help.
Oh, long long. Right, that works. However, isn't this still a
compiler problem since 4.0/4.1 works? Or can you not rely on it
to work because of optimizations?
--
Martin Michlmayr
http://www.cyrius.com/
Reply to: