From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=35670 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PD1vr-0001PW-85 for qemu-devel@nongnu.org; Mon, 01 Nov 2010 17:28:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PD1vo-0005iy-8Y for qemu-devel@nongnu.org; Mon, 01 Nov 2010 17:28:45 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:33430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PD1vo-0005ii-2W for qemu-devel@nongnu.org; Mon, 01 Nov 2010 17:28:44 -0400 Received: by fxm4 with SMTP id 4so5572213fxm.4 for ; Mon, 01 Nov 2010 14:28:43 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4CCF3104.1000005@redhat.com> Date: Mon, 01 Nov 2010 22:28:36 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1288623713-28062-1-git-send-email-agraf@suse.de> <1288623713-28062-3-git-send-email-agraf@suse.de> <4CCF0A13.1060202@mail.berlios.de> <4CCF20BE.8010205@mail.berlios.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 02/40] elf: Add notes implementation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Blue Swirl , Michael Matz , qemu-devel Developers , Gerd Hoffmann On 11/01/2010 10:17 PM, Alexander Graf wrote: > Let's ask someone who definitely knows:). LOL, hi Michael! :) > Michael, is code like > > char *x = a, *y = b; > if (x < y) { > ... > } > > valid? Or do I first have to cast x and y to unsigned longs or uintptr_t? It is, as long as x and y point into the same object (in your original code, data[0]...data[data_len] is the object). This instead char *x = a; long *y = b; if (x < y) { } should give a warning g2.c:1: warning: comparison of distinct pointer types lacks a cast but is also valid as long as x and y point into the same object. To quiet the warning you should _not_ cast x to long* however (unless you know it's properly aligned); casting y to char* instead is fine. Paolo