Path: utzoo!attcan!uunet!mcvax!hp4nl!orcenl!bengsig From: bengsig@oracle.nl (Bjorn Engsig) Newsgroups: comp.lang.c Subject: Re: When is a cast not a cast? Message-ID: <334.nlhp3@oracle.nl> Date: 18 May 89 10:11:53 GMT References: <406@skye.ed.ac.uk> <10276@smoke.BRL.MIL> <2890@buengc.BU.EDU> Reply-To: bengsig@oracle.nl (Bjorn Engsig) Organization: ORACLE Europe, The Netherlands Lines: 54 >>In article <406@skye.ed.ac.uk> richard@aiai.UUCP (Richard Tobin) writes: >>> t = p + q; >> >In article <10276@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>But you haven't told us what this means! > In article <2890@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >It means that you lose the argument, Doug. [I hope I got the quotations right] Pointer addition IS meaningless. Let's take an example of a 3 bit machine with only 0, 1, 2, ... , 7 as the only addresses. Let's also declare char *p, *q; and let p==3 and q==5. Then what is p+q? Which type does it have? The presumed answer of '8' cannot be stored in this machine. > >It's one heck of an optimization if, for some reason, the subtraction >appears in a loop, and the addition does not. No, it probably would not be. Since by the example above, it is seen that you would not be able to represent the pointer sum in a single word. >>What is its type hypothetically supposed to be? > >char * This fails completely. If char *z = p + q (p and q from above) the what is the significance of *z? In article <10276@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>Other postings have explained why we don't think a reasonable, consistent >>model for this feature is possible. True. > --Blair > "Introducing N.O.C.W.A.P.: The National > Organization of Code Writers for > Addable Pointers." Don't count me as a member! BTW, what is the sum of the two 'pointers' earth *russia, *southamerica : 58 45' 22" north, 43 45' 45" east and 23 47' 19" south, 95 13' 18" west (The difference, of course, is a direction and some number of kilometers) -- Bjorn Engsig, ORACLE Europe \ / "Hofstadter's Law: It always takes Path: mcvax!orcenl!bengsig X longer than you expect, even if you Domain: bengsig@oracle.nl / \ take into account Hofstadter's Law"