This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17645] New: Warning flags for unsigned operations (unsafe)
- From: "mmalater at nycap dot rr dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Sep 2004 04:15:45 -0000
- Subject: [Bug c++/17645] New: Warning flags for unsigned operations (unsafe)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Following the discussion on the gcc mailing list. I am posting the feature
request here.
I would like a new flag in gcc that would warn user about possible unsafe
operation when manipulating unsigned numbers. For example, the following code
that does a simple linear interpolation is unsafe:
1.
c = a + t * (b - a); //unsafe
Whereas this one is safe:
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
(mathematically speaking).
It would be nice if there something in gcc that could warn me for this kind of
operation.
This would also be great if the warnings would also work on templated code (so
ex #1 would be half good/half bad depending of signess).
--
Summary: Warning flags for unsigned operations (unsafe)
Product: gcc
Version: 3.3.4
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mmalater at nycap dot rr dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17645