public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17645] New: Warning flags for unsigned operations (unsafe)
@ 2004-09-24  4:15 mmalater at nycap dot rr dot com
  2004-09-24 10:32 ` [Bug c++/17645] Add a warning for potentially unsafe unsigned operations giovannibajo at libero dot it
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: mmalater at nycap dot rr dot com @ 2004-09-24  4:15 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-07-15 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20040924041536.17645.mathieu@malaterre.com>
2005-07-06  2:32 ` [Bug c++/17645] Add a warning for potentially unsafe unsigned operations mathieu at malaterre dot com
2005-07-06  2:34 ` [Bug c/17645] " pinskia at gcc dot gnu dot org
2005-07-06  2:59 ` [Bug c++/17645] " mathieu at malaterre dot com
2005-07-06  3:00 ` [Bug c/17645] " mathieu at malaterre dot com
2005-07-15 20:22 ` falk at debian dot org
2004-09-24  4:15 [Bug c++/17645] New: Warning flags for unsigned operations (unsafe) mmalater at nycap dot rr dot com
2004-09-24 10:32 ` [Bug c++/17645] Add a warning for potentially unsafe unsigned operations giovannibajo at libero dot it
2004-09-24 14:41 ` trt at acm dot org
2004-09-24 14:44 ` pinskia at gcc dot gnu dot org
2004-09-25 16:45 ` mmalater at nycap dot rr dot com
2004-10-28  3:44 ` giovannibajo at libero dot it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).