low level optimization

Jim Giles jlg at cochiti.lanl.gov
Sat Apr 20 05:33:04 AEST 1991


It has been suggested that a program of the following type constitutes
a counterexample to my previous statements about pointers and aliasing:

func(i,j)
char *i;
float *j;
...

However, my original statement about pointers and aliasing was that
pointer arguments to the _same_ underlying type must be assumed to be
aliased to each other and to all globals of that type (as well as any
local object of that type whose address has possibly been assigned
to one of these visible pointers, etc.).

I admit that I also (and distinctly separately) mentioned that a 
prudent C compiler would also assume aliasing in many other cases 
because of the common practice that C programmers seem to covet of 
casting pointers in illegal ways.  It is only in that sense that 
the above type of program is even relevant to anything I have been 
saying. In fact, I do believe that a prudent C implementation should 
assume that i and j in the above are aliased.  But, since such aliasing 
is illegal, it does not trouble me that a standard conforming C compiler
is free to assume that they are _not_ aliased.  Either way, it does
effect my main point.

J. Giles



More information about the Comp.lang.c mailing list