When is a cast not a cast?

Blair P. Houghton bph at buengc.BU.EDU
Wed May 17 22:34:51 AEST 1989


In article <10276 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>In article <406 at skye.ed.ac.uk> richard at aiai.UUCP (Richard Tobin) writes:
>>>Addition of pointers is a meaningless operation.
>>Not always.
[char *t, *p, *q]
>>  t = p + q;
>
>But you haven't told us what this means!

It means that you lose the argument, Doug.

>What properties does t hypothetically have?

It has the property that you can now subtract

    char *pnew, *r;
    pnew = t - r

and expect pnew to point to the location referred to p that is
the same offset as q is referred to r.

It's one heck of an optimization if, for some reason, the subtraction
appears in a loop, and the addition does not.

>What is its type hypothetically supposed to be?

char *

>What can one legally do with it?

What one can legally do between (consenting) integers?

>(Apparently, subtracting r is legal?  What are the official criteria?)

Ask yer second-grade teacher, or get another career.

>Other postings have explained why we don't think a reasonable, consistent
>model for this feature is possible.

"Why we don't think...possible"??  Not only is it possible, it's sensible.
As to whether we think it is so, that is irrelevant.  We don't think
fusion is possible, either, unless we consider that it's going on all
over the place (well, not _all_ over the place, but in all those jillions
of stars...!)

				--Blair
				  "Introducing N.O.C.W.A.P.: The National
				   Organization of Code Writers for
				   Addable Pointers."



More information about the Comp.lang.c mailing list