Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.lang.c Subject: Re: When is a cast not a cast? Message-ID: <1556@auspex.auspex.com> Date: 4 May 89 06:08:54 GMT References: <2747@buengc.BU.EDU> <10191@smoke.BRL.MIL> <2759@buengc.BU.EDU> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 20 >Now, I don't mind being told by the compiler that I'm screwing up by >subtracting pointers that may point to different data spaces (even though >it is my belief that such a subtraction should occur vectorially, and >generate the proper memory offset to get me from ram-byte A to ram-byte B, >going through data/text/etc pages as necessary...) Uhh, offset in *what units*? Pointer subtraction doesn't tell you how many "char"s there are between the pointed-to objects, it tells you how many objects *of the storage type that the pointers both point to* (if they point to different types, you can't subtract them) are between them (well, that plus one - "&foo[0]" and "&foo[1]" have nothing between them, or between them and their Calvin Klein's for that matter, but "&foo[1] - &foo[0]" is 1), under the assumption that they both point to members of an array of objects of that type. >but I find it more than unsettling that a pointer offset can not be >expressed and manipulated directly in the pointer type. Why? "pointer offsets", if by that you mean "the value of one pointer relative to another", aren't the same sorts of objects as pointers.