Warning flags for unsigned operations (unsafe)
Mathieu Malaterre
mmalater@nycap.rr.com
Fri Sep 24 06:31:00 GMT 2004
Giovanni Bajo wrote:
> 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?
Done:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17645
If I did something wrong just let me know, I'll correct it,
Mathieu
More information about the Gcc
mailing list