valid program?

Doug Gwyn gwyn at brl-vgr.ARPA
Sat Apr 7 04:52:07 AEST 1984


main()
{
	int *i, *j;
	&(*i) = j;
}

Your sample program is not valid since an lvalue is required on the
left side of the assignment.  The Ritchie PDP-11 C compiler gets this
right; PCC does not (as of UNIX System V Release 1).  PCC turns &(*i)
into i and proceeds.

One way of looking at this is:  What i points to, (*i), is some
int somewhere, maybe in another module.  The address of that is the
storage location of that other int.  This has nothing to do with i
itself; it may be a load-time constant that cannot be changed.



More information about the Comp.lang.c mailing list