When is a cast not a cast?

Robert J Woodhead trebor at biar.UUCP
Wed May 17 14:00:36 AEST 1989


In article <406 at skye.ed.ac.uk> richard at aiai.UUCP (Richard Tobin) writes:
>>Addition of pointers is a meaningless operation.
>Not always.  (I'm not discussing whether it's legal in C, just whether it's
>meaningless.)

Unfortunately, all the examples you provide depend on the various pointers
pointing into a particular data structure.  What with pointers being
modified inside of functions, etc, etc, it is very difficult for a
compiler to determine that a particular pointer ``addition'' is safe
or not.

The bottom line is, meaningless or not, it is a stupid and dangerous
programming practice that will come back to haunt you, and it removes
semantic information from your program that a decent compiler could
use to your advantage.  Finally, anyone unfortunate enough to be
inflicted with the task of maintaining your code will be seriously
tempted to invoke a voodoo death curse upon you.

	Join the programmers arrayed against pointer addition.
	Just Say No to bugs.

-- 
Robert J Woodhead, Biar Games, Inc.  !uunet!biar!trebor | trebor at biar.UUCP
"The lamb will lie down with the lion, but the lamb won't get much sleep."
     -- Woody Allen.



More information about the Comp.lang.c mailing list