From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13099 invoked by alias); 18 Jul 2005 01:49:50 -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 12318 invoked by uid 22791); 18 Jul 2005 01:49:46 -0000 Received: from vinc17.net4.nerim.net (HELO ay.vinc17.org) (62.212.121.106) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 18 Jul 2005 01:49:46 +0000 Received: from lefevre by ay.vinc17.org with local (Exim 4.52) id 1DuKlK-0007OH-Om; Mon, 18 Jul 2005 03:49:42 +0200 Date: Mon, 18 Jul 2005 01:49:00 -0000 From: Vincent Lefevre To: gcc@gcc.gnu.org Subject: Re: Pointers in comparison expressions Message-ID: <20050718014942.GV18430@ay.vinc17.org> Mail-Followup-To: gcc@gcc.gnu.org References: <1121185961.13154.50.camel@linux-009002219143> <20050712214222.GA90111@falcon.midgard.homeip.net> <20050716114905.GG18430@ay.vinc17.org> <17114.36234.453249.871348@gargle.gargle.HOWL> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17114.36234.453249.871348@gargle.gargle.HOWL> X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.9-vl-20050705i X-SW-Source: 2005-07/txt/msg00753.txt.bz2 On 2005-07-17 12:55:38 -0400, Paul Koning wrote: > Are you sayinvg that a-b is not always "guaranteed to work" when a > and b point to elements of the same array? That sounds wrong; can > you given an example or standards text that supports this? 6.5.6 Additive operators [...] [#9] When two pointers are subtracted, both shall point to elements of the same array object, or one past the last element of the array object; the result is the difference of the subscripts of the two array elements. The size of the result is implementation-defined, and its type (a signed integer type) is ptrdiff_t defined in the header. If the result is not representable in an object of that type, the behavior is undefined. In other words, if the expressions P and Q point to, respectively, the i-th and j- th elements of an array object, the expression (P)-(Q) has the value i-j provided the value fits in an object of type ptrdiff_t. [...] See the sentence "If the result..." and the last few words of the next sentence. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / SPACES project at LORIA