From 4808274652935983863
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-09-11 05:45:00 PST
Newsgroups: comp.std.c++
Path: sparky!uunet!taumet!steve
From: steve@taumet.com (Steve Clamage)
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <1992Sep11.190134.4283@taumet.com>
Organization: TauMetric Corporation
References: <1992Sep10.162906.14398@genghis.borland.com> <4950@holden.lulea.trab.se>
Date: Fri, 11 Sep 1992 19:01:34 GMT
Lines: 27

jbn@lulea.trab.se (Johan Bengtsson) writes:

|pete@genghis.borland.com (Pete Becker) writes:

|: 	0x0000:0x0010
|: 	0x0001:0x0000
|: 
|: These two addresses refer to the same memory location.  Converting them to
|: longs in the most obvious way produces these two values:
|: 
|: 	0x00000010
|: 	0x00010000

|But can this really happen, if the rule "pointer arithmetic only
|within an array" is adhered to?  Shouldn't all pointers within an
|array be based on the same segment?


If you do non-normalized pointer arithmetic, the offset portion could
be greater than 15 and still point within the array.  This causes no
problems for the hardware, which doesn't care whether pointers are
normalized.  The compiler must still arrange for pointer comparisons
to come out right, such as by normalizing them first.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Vice Chair, ANSI C++ Committee, X3J16


