From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17946 invoked by alias); 12 Jul 2005 21:00:00 -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 17924 invoked by uid 22791); 12 Jul 2005 20:59:54 -0000 Received: from ns.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 12 Jul 2005 20:59:54 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id E951EEF89; Tue, 12 Jul 2005 22:59:51 +0200 (CEST) From: Andreas Schwab To: "Dave Korn" Cc: "'Daniel Berlin'" , , Subject: Re: Pointers in comparison expressions References: X-Yow: .. he dominates the DECADENT SUBWAY SCENE. Date: Tue, 12 Jul 2005 21:00:00 -0000 In-Reply-To: (Dave Korn's message of "Tue, 12 Jul 2005 17:54:00 +0100") Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2005-07/txt/msg00523.txt.bz2 "Dave Korn" writes: > Since pointer subtraction is well defined, and it returns an int, then ... > > int *a, *b; > > if (a < b) > dosomething (); > > ... is just the same as ... > > int *a, *b; > > if ((b - a) >= 0) > dosomething (); This may not work correctly if ((char*) b - (char*) a) % sizeof int != 0 (which can happen if __alignof__ int < sizeof int). Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."