From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14475 invoked by alias); 23 Sep 2004 16:11:26 -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 14439 invoked from network); 23 Sep 2004 16:11:23 -0000 Received: from unknown (HELO boden.synopsys.com) (198.182.44.79) by sourceware.org with SMTP; 23 Sep 2004 16:11:23 -0000 Received: from maiden.synopsys.com (maiden.synopsys.com [146.225.100.170]) by boden.synopsys.com (Postfix) with ESMTP id 19C9CDE30; Thu, 23 Sep 2004 09:10:54 -0700 (PDT) Received: from piper.synopsys.com (localhost [127.0.0.1]) by maiden.synopsys.com (8.9.1/8.9.1) with ESMTP id JAA24824; Thu, 23 Sep 2004 09:11:20 -0700 (PDT) Received: (from jbuck@localhost) by piper.synopsys.com (8.11.6/8.11.6) id i8NGBIA03464; Thu, 23 Sep 2004 09:11:18 -0700 X-Authentication-Warning: piper.synopsys.com: jbuck set sender to Joe.Buck@synopsys.com using -f Date: Thu, 23 Sep 2004 18:57:00 -0000 From: Joe Buck To: Dave Korn Cc: "'Andreas Schwab'" , "'Morten Welinder'" , gcc@gcc.gnu.org Subject: Re: signed vs unsigned pointer warning Message-ID: <20040923091118.A2943@synopsys.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: ; from dk@artimi.com on Thu, Sep 23, 2004 at 12:35:22PM +0100 X-SW-Source: 2004-09/txt/msg01348.txt.bz2 On Thu, Sep 23, 2004 at 12:35:22PM +0100, Dave Korn wrote: > > "Dave Korn" writes: > > > > > Which I don't think you can, since you can't store negative numbers > > > in an unsigned type. > > > > Actually you can, due to the modulo behaviour of unsigned integers. > > > > Andreas. > > Well, yes, it is physically possible, but it's a kind of type-punning, it > defies the aliasing rules, and we get into some very deeply > language-lawyerly issues here, but it's not a valid representation IIUIC and > therefore invokes undefined behaviour in many circumstances. The C aliasing rules specifically bless accessing ints as unsigneds, and, more generally, punning accesses between any type and the unsigned version of that type.