public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/37591]  New: suppress "signed and unsigned" warnings when signed value known to be positive
@ 2008-09-19 18:13 zackw at panix dot com
  2008-09-19 20:56 ` [Bug c/37591] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: zackw at panix dot com @ 2008-09-19 18:13 UTC (permalink / raw)
  To: gcc-bugs

In a case such as this, GCC ought to be able to prove that the signed variable
is positive and therefore suppress "signed and unsigned" warnings.  I see this
in both C and C++.

#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))

unsigned int
constrain(unsigned int index, unsigned int offset, unsigned int limit)
{
  int adj = index - offset;
  adj = MAX(adj, 0);
  return MIN(adj, limit); /* { dg-bogus "signed and unsigned" } */
}


-- 
           Summary: suppress "signed and unsigned" warnings when signed
                    value known to be positive
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zackw at panix dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37591


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <bug-37591-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-07-06 12:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-19 18:13 [Bug c/37591] New: suppress "signed and unsigned" warnings when signed value known to be positive zackw at panix dot com
2008-09-19 20:56 ` [Bug c/37591] " pinskia at gcc dot gnu dot org
2008-09-19 21:29 ` zackw at panix dot com
2008-09-20  9:11 ` rguenth at gcc dot gnu dot org
2008-09-22 13:29 ` manu at gcc dot gnu dot org
2008-09-22 15:47 ` zackw at panix dot com
2008-09-22 16:44 ` manu at gcc dot gnu dot org
     [not found] <bug-37591-4@http.gcc.gnu.org/bugzilla/>
2015-07-06  8:59 ` daniel.marjamaki at gmail dot com
2015-07-06 12:31 ` manu at gcc dot gnu.org

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).