From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24840 invoked by alias); 21 Sep 2004 18:26:21 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 24825 invoked from network); 21 Sep 2004 18:26:20 -0000 Received: from unknown (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org with SMTP; 21 Sep 2004 18:26:20 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.12.11/8.12.10) with ESMTP id i8LIPHZr023723; Tue, 21 Sep 2004 14:25:17 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i8LIQJ727726; Tue, 21 Sep 2004 14:26:19 -0400 Received: from frothingslosh.sfbay.redhat.com (frothingslosh.sfbay.redhat.com [172.16.24.27]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i8LIQIV27281; Tue, 21 Sep 2004 11:26:18 -0700 Received: from frothingslosh.sfbay.redhat.com (localhost.localdomain [127.0.0.1]) by frothingslosh.sfbay.redhat.com (8.12.10/8.12.10) with ESMTP id i8LIQIOo031368; Tue, 21 Sep 2004 11:26:18 -0700 Received: (from rth@localhost) by frothingslosh.sfbay.redhat.com (8.12.10/8.12.10/Submit) id i8LIQIdg031366; Tue, 21 Sep 2004 11:26:18 -0700 X-Authentication-Warning: frothingslosh.sfbay.redhat.com: rth set sender to rth@redhat.com using -f Date: Tue, 21 Sep 2004 20:52:00 -0000 From: Richard Henderson To: gcc@gcc.gnu.org Cc: torvalds@osdl.org Subject: signed vs unsigned pointer warning Message-ID: <20040921182618.GA31349@redhat.com> Mail-Followup-To: Richard Henderson , gcc@gcc.gnu.org, torvalds@osdl.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2004-09/txt/msg01250.txt.bz2 [ Forwarded from the thread beginning at http://marc.theaimsgroup.com/?l=linux-sparse&m=109577992701909&w=2 ] On Tue, Sep 21, 2004 at 09:49:43AM -0700, Linus Torvalds wrote: > In fact, even the "explicit sign" differences are a bit questionable. The > xdr4 code does something like this: > > s64 len, start, end; > ... > p = xdr_decode_hyper(p, &start); > p = xdr_decode_hyper(p, &len); > .. > > and both of these generate warnings, because xdr_decode_hyper() looks like > > static inline u32 * > xdr_decode_hyper(u32 *p, __u64 *valp) > > but the fact is, it obviously works fine to return both u64 and s64 > values, and forcing the caller to use one over the other is just not that > sensible. Maybe. Or maybe it's a bug that the caller typo'd s64 instead of u64, and (start < end) will mistakenly compare false when end gets large. > ... and duplicating the function to do the same thing also seems > totally idiotic. I don't agree. If signed vs unsigned really isn't important, because xdr_decode_hyper does no range checking, yadda yadda, then static inline u32 * xdr_decode_hyper_s(u32 *p, s64 *valp) { return xdr_decode_hyper (p, (u64 *) valp)); } does not seem too much to ask. > Richard, are you sure that the gcc team has thought this through wrt > gcc-4.0, or is this just another total disaster like adding > "-Wsign-compare" to the default flags in gcc-3.0? I think we're on more solid ground here than -Wsign-compare, because the types "int *" and "unsigned int *" are not compatible [c99 6.2.7]. IANAL, but we could be within our rights to reject the program entirely [c99 6.5.16.1]. I am finding it somewhat annoying that there's no -W switch to turn it off though, since there are three include/linux/ headers that now prevent me from using -Werror under arch/alpha/. r~