Converting FORTRAN to C

David Herron, NPR Lover david at ukma.UUCP
Sun Jan 6 08:53:42 AEST 1985


In article <103 at physiol.OZ>, john at physiol.OZ (John Mackin) writes:
>In article <435 at ukma.UUCP>, david at ukma.UUCP (David Herron, NPR Lover) writes:

>> Any program that is referencing outside
>> the bounds of an array is already broken, and should be shot on
>> sight. :-)  (unless it can give good reason for behaving in such a manner).

>Now, sure you could say "p <= &array[ARRARYSIZE - 1]" instead.  But which
>is clearer, and easier to read ... and, more importantly, used in many,
>many places in V7 UNIX as distributed by AT&T?  I get VERY ANGRY at compilers
>like Whitesmiths' (for VAX/VMS, at least) that get upset about this construct.

>After all, this is C, not PASCAL or some other wimp's language that
>checks array bounds. :-)

Aaaaahhhhhhh, but your code is not a *real* reference.  It is simply
a calculation of an address, and knowledge that for this array, a
certain address is a good trailer value.  I of course meant in my
posting that any program that WRITES outside an array is already
broken.  (I know, I know, there are times when even that can be useful,
such as the following #define's I wrote for someone with C on an apple.
And ya know how them Apple programmers just can't program without
putting in poke statements :-) .)

	#define poke(adr,val)	(*((char *)adr)) = ((char)val)
	#define peek(adr)	(*((char *)adr))

And Whitesmith's should be shot for being such a terminally *almost good*
compiler.



More information about the Comp.lang.c mailing list