Are literal strings and function return values lvalues or rvalues?

  1. string literals are lvalues, but you can’t change them
  2. rvalue, but if it’s a pointer and non-NULL, the object it points to is an lvalue

The C standard recognizes the original terms stood for left and right as in L = R; however, it says to think of lvalue as locator value, which roughly means you can get the address of an object and therefore that object has a location. (See in C99.)

By the same token, the standard has abandoned the term rvalue, and just uses “the value of an expression”, which is practically everything, including literals such as ints, chars, floats, etc. Additionally, anything you can do with an rvalue can be done with an lvalue too, so you can think of all lvalues as being rvalues.

Leave a Comment