When is a cast not a cast?

Bjorn Engsig bengsig at oracle.nl
Thu May 18 20:11:53 AEST 1989


>>In article <406 at skye.ed.ac.uk> richard at aiai.UUCP (Richard Tobin) writes:
>>>  t = p + q;
>>
>In article <10276 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>But you haven't told us what this means!
>
In article <2890 at buengc.BU.EDU> bph at 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 at smoke.BRL.MIL> gwyn at 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 at oracle.nl           / \     take into account Hofstadter's Law"



More information about the Comp.lang.c mailing list