From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30398 invoked by alias); 12 Jul 2005 16:53:55 -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 30374 invoked by uid 22791); 12 Jul 2005 16:53:53 -0000 Received: from host217-40-213-68.in-addr.btopenworld.com (HELO SERRANO.CAM.ARTIMI.COM) (217.40.213.68) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 12 Jul 2005 16:53:53 +0000 Received: from mace ([192.168.1.25]) by SERRANO.CAM.ARTIMI.COM with Microsoft SMTPSVC(6.0.3790.211); Tue, 12 Jul 2005 17:53:47 +0100 From: "Dave Korn" To: "'Daniel Berlin'" , Cc: Subject: RE: Pointers in comparison expressions Date: Tue, 12 Jul 2005 16:53:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In-Reply-To: <1121185961.13154.50.camel@linux-009002219143> Message-ID: X-SW-Source: 2005-07/txt/msg00509.txt.bz2 ----Original Message---- >From: Daniel Berlin >Sent: 12 July 2005 17:33 >> I think that even if the use of relational operators other than '==' and >> '!=' is legal with pointers, the compiler should issue a warning (when >> the option -Wall is used), as it does for assignment, used as truth >> values, not surrounded with parentheses. > > Why? > It's legal, it's useful, and used. > > --Dan Just to enlarge upon Dan's comment: 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 (); ... so do you think the compiler should warn about _all_ pointer arithmetic? cheers, DaveK -- Can't think of a witty .sigline today....