This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Warning flags for unsigned operations (unsafe)


Hello,

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 ?

Thanks,
Mathieu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]