When is a cast not a cast?

usenet usenet at TSfR.UUCP
Thu May 18 15:52:39 AEST 1989


In article <2890 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
[more discussion of the properties of pointer+pointer]
>
>>What is its type hypothetically supposed to be?
>
>char *
>
>>What can one legally do with it?
>
>What one can legally do between (consenting) integers?

  Eeek.  Hopefully not.  If it's integerish, it associates & commutes,
  and if it's a pointer, well....

    pointer-pointer yields an int

  replace a pointer with a pointer+pointer....

    (pointer+pointer)-pointer yields an int

  then rearrange the parenthesis....

    pointer+(pointer-pointer) yields an int

  you'd get (using pointer-pointer yields an int) ...

    pointer+int yields an int

  which conflicts with...

    pointer+int yields a pointer

> ... Not only is it possible, it's sensible.

  Not really, not with the abilities you give it above.

  What does pointer+pointer give you, aside from clever loop optimizations?
  Wouldn't the task of loop optimizing be better served by making a type
  that holds pointer+pointer values and that can have a pointer subtracted
  from it to yield another pointer, but doesn't allow any other operation?



   -david parsons
   -orc at pell.uucp



More information about the Comp.lang.c mailing list