Yet Another Silly Question

Guy Harris guy at auspex.auspex.com
Wed Jun 7 03:29:35 AEST 1989


>Also, the scaling operation has simply been moved to the "for" line, as
>far as I can tell.  The machine still has to dereference &a[MAX] on each
>iteration of the loop, doesn't it?

I presume you mean "compute" rather than "dereference".  (I should *hope*
it doesn't dereference the pointer value "&a[MAX]"; since "a" has "MAX"
elements, the last element is "&a[MAX-1]", so dereferencing "&a[MAX]"
could cause all sorts of problems....)

>It really has no way of knowing that &a[MAX] won't change during the
>course of the program,

Say what?  It knows that "MAX" is a constant (assuming this is vanilla
C, and not, say, C as extended by compilers such as GCC that permit you
to declare automatic arrays of variable size), and it knows that "a"
isn't going to move, so it knows that "&a[MAX]" will always be the same
address.



More information about the Comp.lang.c mailing list