While reading this explanation on lvalues and rvalues, these lines of code stuck out to me:
int& foo(); foo() = 42; // OK, foo() is an lvalue
int& foo(); is a function returning a reference to int. Your provided function returns int without reference.
int& foo();
int
You may do
int& foo() { static int i = 42; return i; } int main() { int& foo(); foo() = 42; }