From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 30232 invoked from network); 4 Feb 1999 11:33:10 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 4 Feb 1999 11:33:10 -0000 Received: from axl01it.ntc.nokia.com (axl01it.ntc.nokia.com [131.228.118.232]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id GAA09369 for ; Thu, 4 Feb 1999 06:25:40 -0500 Received: from ducati.uk.ntc.nokia.com (ducati.uk.ntc.nokia.com [131.228.132.169]) by axl01it.ntc.nokia.com (8.8.5/8.6.9) with ESMTP id NAA08575 for ; Thu, 4 Feb 1999 13:24:49 +0200 (EET) Received: from cpd.ntc.nokia.com (mvagusta [131.228.132.173]) by ducati.uk.ntc.nokia.com (8.6.9/8.6.9) with ESMTP id LAA07843 for ; Thu, 4 Feb 1999 11:25:34 GMT Sender: carmody@cpd.ntc.nokia.com Message-ID: <36B983AE.54A8BFA0@cpd.ntc.nokia.com> Date: Thu, 04 Feb 1999 11:25:34 +0000 From: Phil Carmody X-Mailer: Mozilla 4.5 [en] (X11; I; SunOS 5.5.1 sun4m) X-Accept-Language: en MIME-Version: 1.0 To: axp-list@redhat.com Subject: Re: So Y is my pointer so bogus References: <36B8CF6A.D373F882@voicenet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Uncle George wrote: > > This little example caused a (un-expected ) pointer failure in one of > the font routines in my java 1.2 port on linux/alpha. It was expected to > add a -1760 ( -1760 * sizeof(int)) but does not. > a = (int *)a +(x2-x1-x3)*P + (y2-y1-y3)*S; in expressions of the form int * unsigned The int gets promoted to the unsigned type. The value therefore is _not_ -1760, it 0xFFFF~~~~ When promoted to a 64bit type (e.g. (type*)) as it's unsigned it will become 0x00000000FFFF~~~~ and then scaled by sizeof(type) It's doing exactly what was programmed, the programmer was in error. If you want the difference between pointers, why not use ptrdiff_t? That _is_ what it was invented for. FatPhil -- Phil Carmody Not speaking for or on behalf of Nokia Telecommunications. "At the showing of blue movies at Scotland Yard I take the precaution of removing my glasses, which reduces the whole messy business to an impressionist blur." John Mortimer, QC, 1978