From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6677 invoked by alias); 12 Jul 2005 17:03:49 -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 6524 invoked by uid 22791); 12 Jul 2005 17:03:33 -0000 Received: from mailgw.cs.york.ac.uk (HELO mailgw.cs.york.ac.uk) (144.32.40.3) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 12 Jul 2005 17:03:33 +0000 Received: from minster.cs.york.ac.uk ([144.32.40.2]) by mailgw.cs.york.ac.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1DsO65-0007g2-G8; Tue, 12 Jul 2005 17:59:05 +0100 Received: from bushfire.cs.york.ac.uk ([144.32.40.24] helo=[192.168.112.229]) by minster.cs.york.ac.uk with esmtp (Exim 4.44) id 1DsO65-0003SX-91; Tue, 12 Jul 2005 17:59:05 +0100 Message-ID: <42D3F6D6.9090806@cs.york.ac.uk> Date: Tue, 12 Jul 2005 17:03:00 -0000 From: chris jefferson User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) MIME-Version: 1.0 To: mrc.lrn@inwind.it CC: gcc@gcc.gnu.org Subject: Re: Pointers in comparison expressions References: <200507121825.45472.mrc.lrn@inwind.it> In-Reply-To: <200507121825.45472.mrc.lrn@inwind.it> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-SW-Source: 2005-07/txt/msg00510.txt.bz2 Mirco Lorenzoni wrote: >Can a pointer appear in a C/C++ relational expression which doesn't test the >equality (or the inequality) of that pointer with respect to another pointer? >For example, are the comparisons in the following program legal code? > >/* test.c */ >#include > >int main(int argc, char* argv[]) >{ > void *a, *b; > int aa, bb; > > a = &aa; > b = &bb; > > > Actually I'm fairly certain at this point this program stops being legal code, as (I believe) you can only compare pointers which are from the same allocation (be that an array, malloc, etc). However, comparing pointers with < is something I do all the time when writing various kinds of algorithms. For what reason would you want to see it warned about? Chris