From owner-freebsd-amd64@FreeBSD.ORG Sun Mar 1 05:35:14 2009 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4425F1065673 for ; Sun, 1 Mar 2009 05:35:14 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: from sopwith.solgatos.com (pool-173-50-229-3.ptldor.fios.verizon.net [173.50.229.3]) by mx1.freebsd.org (Postfix) with ESMTP id B3BF38FC0C for ; Sun, 1 Mar 2009 05:35:12 +0000 (UTC) (envelope-from freebsd@sopwith.solgatos.com) Received: by sopwith.solgatos.com (Postfix, from userid 66) id 4D688B64F; Sat, 28 Feb 2009 21:17:59 -0800 (PST) Received: from localhost by sopwith.solgatos.com (8.8.8/6.24) id VAA17590; Sat, 28 Feb 2009 21:06:41 GMT Message-Id: <200902282106.VAA17590@sopwith.solgatos.com> To: freebsd-amd64@freebsd.org Date: Sat, 28 Feb 2009 13:06:41 +0000 From: Dieter Subject: Re: 32-bit truncation of 64-bit values X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd@sopwith.solgatos.com List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Mar 2009 05:35:14 -0000 > Having just tracked down an issue caused by a pointer-to-int truncation, Was this in C? Didn't the compiler complain? cat demo_ptr_into_int.c ; gcc -O3 -o demo_ptr_into_int demo_ptr_into_int.c ; ./demo_ptr_into_int /* demo_ptr_into_int.c * * Verify that compiler complains about truncation when * attempting to stuff a 64 bit pointer into a 32 bit int. */ #include /* for printf(3) */ int main(int argc, char **argv) { int i; int *p; p = &i; i = p; printf("i = 0x%x p = 0x%p\n", i, p); return(0); } demo_ptr_into_int.c: In function 'main': demo_ptr_into_int.c:16: warning: assignment makes integer from pointer without a cast i = 0xffffebc4 p = 0x0x7fffffffebc4 Adding a cast still yields a complaint: i = (int) p; demo_ptr_into_int.c: In function 'main': demo_ptr_into_int.c:16: warning: cast from pointer to integer of different size