From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26350 invoked by alias); 18 Jul 2005 13:09:07 -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 26255 invoked by uid 22791); 18 Jul 2005 13:08:55 -0000 Received: from sadr.equallogic.com (HELO sadr.equallogic.com) (66.155.203.134) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Mon, 18 Jul 2005 13:08:55 +0000 Received: from sadr.equallogic.com (localhost.localdomain [127.0.0.1]) by sadr.equallogic.com (8.12.8/8.12.8) with ESMTP id j6ID8fZZ011621 for ; Mon, 18 Jul 2005 09:08:41 -0400 Received: from M31.equallogic.com (M31.equallogic.com [172.16.1.31]) by sadr.equallogic.com (8.12.8/8.12.8) with SMTP id j6ID8cNd011616; Mon, 18 Jul 2005 09:08:40 -0400 Received: from pkoning.equallogic.com ([172.16.1.163]) by M31.equallogic.com with Microsoft SMTPSVC(6.0.3790.211); Mon, 18 Jul 2005 09:08:38 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17115.43477.670158.321199@gargle.gargle.HOWL> Date: Mon, 18 Jul 2005 13:09:00 -0000 From: Paul Koning To: vincent+gcc@vinc17.org Cc: gcc@gcc.gnu.org Subject: Re: Pointers in comparison expressions 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> <20050718014942.GV18430@ay.vinc17.org> X-SW-Source: 2005-07/txt/msg00774.txt.bz2 >>>>> "Vincent" == Vincent Lefevre writes: Vincent> 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? Vincent> 6.5.6 Additive operators [...] [#9] When two pointers are Vincent> subtracted, both shall point to elements of the same array Vincent> object, or one past the last element of the array object; Vincent> the result is the difference of the subscripts of the two Vincent> array elements. The size of the result is Vincent> implementation-defined, and its type (a signed integer type) Vincent> is ptrdiff_t defined in the header. If the Vincent> result is not representable in an object of that type, the Vincent> behavior is undefined. In other words, if the expressions P Vincent> and Q point to, respectively, the i-th and j- th elements of Vincent> an array object, the expression (P)-(Q) has the value i-j Vincent> provided the value fits in an object of type ptrdiff_t. Vincent> [...] Vincent> See the sentence "If the result..." and the last few words Vincent> of the next sentence. Bizarre. Is there a real world example where this is done? I can't imagine any place where this exception is justified. paul