This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/37591] New: suppress "signed and unsigned" warnings when signed value known to be positive
- From: "zackw at panix dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Sep 2008 18:12:32 -0000
- Subject: [Bug c/37591] New: suppress "signed and unsigned" warnings when signed value known to be positive
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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