[Main]
Title=Lvalues and Rvalues

[Top]
All expressions in C language may be classified to <B>lvalues</B> and
<B>rvalues</B>.
<BR><BR>
An <B>lvalue</B> is an object locator: an expression that designates an object.
Any variable is an lvalue for example. Another example of an lvalue expression is
<CODE>'*<I>P</I>'</CODE>, where <CODE><I>P</I></CODE> is any expression evaluating
to a non-null pointer. See <A HREF="$$LINK(deref)">dereference operator</A> for more information.
<BR><BR>
A <B>modifiable lvalue</B> is an identifier or expression that relates to an object
that can be accessed and legally changed in memory. A const pointer to a constant, for example,
is not a modifiable lvalue. A pointer to a constant can be changed (but its dereferenced value
cannot).
<BR><BR>
Historically, the "l" stood for "left", meaning that an lvalue could legally
stand on the left (the receiving end) of an <A HREF="$$LINK(assign)">assignment statement</A>. Now, only
modifiable lvalues can legally stand on the left of an assignment statement.
For example, if <CODE>'a'</CODE> and <CODE>'b'</CODE> are nonconstant integer identifiers with properly
allocated memory storage, they are both modifiable lvalues, and assignments such as
<PRE>a = 1;
b = a + b;
</PRE>
are legal. From the other side, the expression
<PRE>a + b
</PRE>
is not an lvalue: <CODE>'a&nbsp;+&nbsp;b&nbsp;=&nbsp;a'</CODE> is illegal because the expression on the left is
not related to an object. Such expressions are often called rvalues (short for "right values").
<BR><BR>
<B>Note:</B> In GNU C, the class of lvalue expressions is wider than in other C dialects; see section
<A HREF="$$INFOLINK(gnuexts/SEC70)">Generalized Lvalues</A> for more info.
