From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31079 invoked by alias); 19 Sep 2008 18:13:53 -0000 Received: (qmail 29899 invoked by uid 48); 19 Sep 2008 18:12:32 -0000 Date: Fri, 19 Sep 2008 18:13:00 -0000 Subject: [Bug c/37591] New: suppress "signed and unsigned" warnings when signed value known to be positive X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "zackw at panix dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-09/txt/msg02274.txt.bz2 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