Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!buengc!bph From: bph@buengc.BU.EDU (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: When is a cast not a cast? Message-ID: <2759@buengc.BU.EDU> Date: 3 May 89 17:13:41 GMT References: <2747@buengc.BU.EDU> <10191@smoke.BRL.MIL> Reply-To: bph@buengc.bu.edu (Blair P. Houghton) Followup-To: comp.lang.c Organization: Boston Univ. Col. of Eng. Lines: 25 In article <10191@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >In article <2747@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >>10 p = (c + (char *) i); /* More trouble than it's worth... */ > >Addition of pointers is a meaningless operation. Philosophically, it's rubbish. According to the language def., it's pure science. Apparently, in C, one can not only add apples to oranges and get more oranges, one can add nothing but apples to the oranges, not even oranges themselves. 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...) but I find it more than unsettling that a pointer offset can not be expressed and manipulated directly in the pointer type. At least, not without first multiplying or dividing by the proper sizeof(*type). --Blair "A little older, marginally wiser..."