Warning flags for unsigned operations (unsafe)
Giovanni Bajo
giovannibajo@libero.it
Fri Sep 24 06:20:00 GMT 2004
Mathieu Malaterre wrote:
> I have been googling around and I couldn't find out if gcc had a
> warning flag for unsigned operation. For example, even the linear
> interpolation on [a,b] can be tricky to code:
>
> 1.
> c = a + t * (b - a); //unsafe
>
> 2.
> c = (1.0 - t) * a + t * b; //safe
>
> Number 1 will fail when both a and b are unsigned and let say b - a =
> -1 (math speaking). Is there something in gcc that could warn me for
> this kind of operation ?
Would you please file a bug report in Bugzilla and later mark it as a
enhancement request?
Thanks.
Giovanni Bajo
More information about the Gcc
mailing list