Casting a postdecrement operand

Jerry Schwarz jss at ulysses.UUCP
Mon Jun 16 05:10:53 AEST 1986


> 
> The variable 'cbap' is a pointer. The cast '(struct abc *)' is a
> pointer cast. I can use '((struct abc *)cbap)' with indirects and
> subscripts and anywhere that I can use an Lvalue, so I really believe
> that the expression is legal.
> 	-bill davidsen

Being a pointer value is not the same as being an lvalue. The places
that require lvalues are left hand side of assignments, and operands
of the increment and decrement operations. In none of these locations
is '((struct abc*)cbap)' legal.

If p is an expression with a (data) pointer type then *p will
be an lvalue, so 
	++ *((struct abc**)&cbab) 
will modify cbab.

Jerry Schwarz
Bell Labs, MH



More information about the Comp.lang.c mailing list