A function call is always an rvalue. True or false?
-
True
-
False
A function call is not always an rvalue in C/C++. Whether it's an rvalue depends on the return type - if a function returns by value, the call is an rvalue, but if it returns a reference, it can be an lvalue. For example, a function returning int& can be used as an lvalue.
False is correct. An rvalue is a temporary value that can appear only on the right of an assignment, while an lvalue refers to an addressable object. In C, function calls indeed always yield rvalues since C has no reference-return types. But in C++, a function can be declared to return a reference (e.g., int& foo();), and a call to such a function is an lvalue — you can legally write foo() = 5;. Because the statement claims function calls are 'always' rvalues, a single counterexample (reference-returning functions) makes the universal claim false. This is a classic C++ trick question testing understanding that return type, not just 'it's a function call', determines value category.