What is the reasoning behind the naming of "lvalue" and "rvalue" in C/C++?
-
1As you know what they are, why do you ask then? – Kiril Kirov Apr 02 '13 at 13:52
-
2Ridiculous that this has been down-voted so much. It's a perfectly clear and valid question, not always explained in web articles on the topic, and the answer is helpful in remembering which value type is which. Very worthwhile. – Syndog Jun 23 '15 at 21:10
-
@Syndog No it's problematic because C and C++ never used exactly the same terminology and now C++ has many more categories. – curiousguy Aug 29 '19 at 20:46
-
1@curiousguy - All the more reason to ask. The only time asking why is problematic is when there's no good answer. – Syndog Aug 31 '19 at 10:40
-
@Syndog It means that there will be two answers: C and C++. Some ppl will only know the answer for one language. It's considered bad style by some ppl here to ask such multiple Q. Some ppl will even downvote you just for having both C and C++ tags! – curiousguy Aug 31 '19 at 14:51
-
@curiousguy - A question that requires explaining a difference between C and C++? You're right, that just crosses the line. Grossly problematic. – Syndog Sep 01 '19 at 19:11
-
@Syndog Not my line, not my rules. I'm telling you because *other ppl* will downvote you just for that. – curiousguy Sep 01 '19 at 20:59
-
1@curiousguy - I'm sure that's true, but it hardly qualifies an otherwise valid and helpful question as "problematic." – Syndog Sep 03 '19 at 16:23
-
“Many more categories” of values in C++ mentioned by @curiousguy: https://en.cppreference.com/w/cpp/language/value_category – arseniiv Dec 15 '22 at 18:13
6 Answers
The standard mentions this:
An lvalue (so called, historically, because lvalues could appear on the left-hand side of an assignment expression) [...]
An rvalue (so called, historically, because rvalues could appear on the right-hand side of an assignment expression) [...]
That is, an lvalue was something you could assign to and an rvalue was something you could assign from.
However, this has gradually gotten further and further from the truth. A simple example of an lvalue that you can't assign it is a const
variable.
const int x = 5;
x = 6; // Error
You can even have an rvalue appear on the left side of an assignment when you involve operator overloading.
I find it more useful to think of an lvalue as referencing an object stored in memory and an rvalue as just a value (that may have been read from memory). The concepts mirror this idea quite well. Some examples:
- Lvalue-to-rvalue can be considered the reading of a value from an object in memory.
- Most operators require lvalue-to-rvalue conversion because they use the value of the object to calculate a result.
- The address of operator (
&
) requires an lvalue because you can only take the address of something in memory. It doesn't need to get the value of the object to work out its address. - Performing
std::move
to turn an lvalue expression into an rvalue expression can be thought of as tricking the compiler into thinking the object that's stored in memory is actually just a temporary value.
However, this also doesn't hold up in every situation. It's just a reasonable analogy.

- 1
- 1

- 108,238
- 20
- 242
- 324
-
-
"_The address of operator (&) requires an lvalue because_" ...because it's so. It's the rule, period. – curiousguy Aug 29 '19 at 20:47
-
Further reading: https://en.cppreference.com/w/cpp/language/value_category – arseniiv Dec 15 '22 at 18:14
Back in the olden days, an "lvalue" meant something that could go on the left side of an assignment, and an "rvalue" meant something that could go on the right side of an assignment.

- 74,985
- 8
- 76
- 165
It's pretty intuitive if you think about what side of an assignment operator they can appear:
left-value = right-value;
Loosely put, lvalue
means you can assign to it, rvalue
means it can only appear on the right hand side of the operator.

- 253,575
- 64
- 457
- 625
-
3... except the meaning has changed over time, and you can have an *rvalue* on the left or require an *lvalue* on the right for user defined assignment operators... but yes, historically this is the reason. – David Rodríguez - dribeas Apr 02 '13 at 13:53
In C, lvalue
and rvalue
reflect the usage in the assignment operator. rvalue
can appear only to the right of =
, while lvalue
can be on either side. In C++ it's similar, but more complicated.
There are non-assignable lvalues
, constant variables.

- 61,140
- 12
- 83
- 180
This is the result of the simplification of a (somewhat more complex) concept.
lvalue
s are left values, i. e. those which "can be on the left side of an assignment". This is, again, a simplification, not all lvalues can be directly assigned to as-is (for example, arrays can't, only elements of a non-const
arrays, so subscripting is required).
rvalues
are right values, those which can only be on the right side of an assignment expression.
The 'l' in lvalue originated from 'left' value (as in from the left-hand side of the assignment operator); however, it now stands for location value, and refers to any object that occupies some identifiable location in memory (i.e. has an address). An rvalue is now anything that is not an lvalue.

- 603
- 5
- 19