From C in a Nutshell:
An lvalue is an expression that designates an object, and it can appear on the left side of an assignment operator.
An lvalue can always be resolved to the corresponding object’s address, unless the object is a bit-field or a variable declared with the register storage class.
Given a lvalue which can't be resolved to the corresponding object's address, how can the lvalue designate an object, and appear on the left side of an assignment operator?
I think that the following three statements are equivalent:
and either of them can be used as a definition of lvalue. Am I right?
Thanks.
The minimum addressability resolution is the char
. If you want a bit field, that's one or more bits within a char
so cannot have its own address, unless you were to allow addresses like 42.6
which would blow the heads off most coders :-)
Variables with register storage class generally can't be addressed because they're not necessarily stored anywhere in memory - that is, after all, what the register storage class means: try to keep this value in a register.
But, even though you cannot get an address for those objects, that doesn't mean you cannot assign to them. For objects held in registers, you just change the register.
And, for bit fields, you can just use the Boolean operations like and/or
to manipulate parts of an addressable value.