[net.lang.c] valid program?

gibbons@boulder.UUCP (Doug Gibbons) (04/05/84)

Is this a valid  program?

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

gwyn@brl-vgr.ARPA (Doug Gwyn ) (04/06/84)

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.

ron@brl-vgr.ARPA (Ron Natalie <ron>) (04/06/84)

No.  &(expr) is not an lvalue.  Lvalues are from the set of
	identifer
	primary[expression]
	lvalue.identifier
	primary->identifier
	*expression
	(lvalue)

You will note that "& thingy" is not one of them.
So you are syntactically incorrect.

-Ron