From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31828 invoked by alias); 6 Oct 2003 17:23:08 -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 31821 invoked from network); 6 Oct 2003 17:23:07 -0000 Received: from unknown (HELO mail.shareable.org) (81.29.64.88) by sources.redhat.com with SMTP; 6 Oct 2003 17:23:07 -0000 Received: from mail.shareable.org (localhost [127.0.0.1]) by mail.shareable.org (8.12.8/8.12.8) with ESMTP id h96HN7md000696; Mon, 6 Oct 2003 18:23:07 +0100 Received: (from jamie@localhost) by mail.shareable.org (8.12.8/8.12.8/Submit) id h96HN7KQ000694; Mon, 6 Oct 2003 18:23:07 +0100 Date: Mon, 06 Oct 2003 17:23:00 -0000 From: Jamie Lokier To: Falk Hueffner Cc: Joe Buck , gcc@gcc.gnu.org Subject: Re: Suggested warning: "negating an expression of unsigned type does not yield a negative value" Message-ID: <20031006172307.GC559@mail.shareable.org> References: <87zngev8i4.fsf@student.uni-tuebingen.de> <20031006085958.A12894@synopsys.com> <87pthauz1i.fsf@student.uni-tuebingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pthauz1i.fsf@student.uni-tuebingen.de> User-Agent: Mutt/1.4.1i X-SW-Source: 2003-10/txt/msg00160.txt.bz2 Falk Hueffner wrote: > > The C and C++ standards require that unsigned values obey modulo 2**N > > arithmetic, so the value of -x is rigorously defined. > > Sure it is. But it is not what is intended. Example: x = 5, then > -x=4294967291, i.e., p will be advanced by 4294967291 bytes, which is > way beyond the legal range of p, but happens to work anyway on 32 bit > architectures (but not on 64 bit architectures). Good point. That's elusive enough that I saw ptr[-x] and thought it was was fine; I am now humbly corrected. -- Jamie