Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: lvalues (was Re: Question about type casting) Message-ID: <7131@brl-smoke.ARPA> Date: 19 Jan 88 14:57:42 GMT References: <546@xyzzy.UUCP> <5080012@hpfcdc.HP.COM> <10227@mimsy.UUCP> <2975@killer.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 27 In article <2975@killer.UUCP> jfh@killer.UUCP (The Beach Bum) writes: >In article <10227@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: >> The result of a cast is an `rvalue' (R for Right: or in other words, >> the kind of thing one finds on the right hand side of an assignment). >> Assignments may be made only to `lvalues' (L for Left: the kind of >> thing found on the left hand side of an assignment). The C indirection >> operator `*' takes an rvalue and yeilds an lvalue, hence the result >> of `* (int *) c' is an lvalue. >Chris, that's some good voodoo. A cast takes an object of whatever >type it happens to be, and whatever state of (l|r)value-ness and changes >it's type, but not it's (l|r)value-ness. If you don't know what you're talking about, you should shut up! Chris is right (as usual) -- a cast produces a non-lvalue (which you may call an `rvalue' if you wish), and it is only the result of applying a * operator that is an lvalue as required for the target of the assignment. A cast performs a simultaneous conversion and virtual assignment of its operand into an unnamed temporary register, in effect. There is no way that the result can be conceived of as being addressable. >The only restriction on what can be on the left hand side of an `=' is >having an address and a type, or being finaglable into having both. Wrong -- it must be a modifiable lvalue.