Primary Expressions

Primary expressions fall into the following general categories:

Names

The value of a name depends on its type, which is determined by how that name is declared. The following table shows whether a name is an lvalue expression.

Primary expressions: Names
Name declared as Evaluates to Is an lvalue
Variable of arithmetic, pointer, enumeration, structure, or union type An object of that type Lvalue
Enumeration constant The associated integer value Not an lvalue
Array That array. In contexts subject to conversions, a pointer to the first object in the array, except where the name is used as the argument to the sizeof operator. C Not an lvalue
Function That function. In contexts subject to conversions, a pointer to that function, except where the name is used as the argument to the sizeof operator, or as the function in a function call expression.

C Not an lvalue

C++ Lvalue

As an expression, a name may not refer to a label, typedef name, structure component name, union component name, structure tag, union tag, or enumeration tag. Names that can be referred to by a name in an expression reside in a name space that is separate from that of names for these purposes. Some of these names may be referred to within expressions by means of special constructs. For example, the dot or arrow operators may be used to refer to structure and union component names; typedef names may be used in casts or as an argument to the sizeof operator.

Literals

A literal is a numeric constant or string literal. When a literal is evaluated as an expression, its value is a constant. A lexical constant is never an lvalue. However, a string literal is an lvalue.

Related References

IBM Copyright 2003