This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Warning flags for unsigned operations (unsafe)
- From: Mathieu Malaterre <mmalater at nycap dot rr dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 21 Sep 2004 20:35:33 -0400
- Subject: 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