title: What does "int& foo()" mean in C++?
body: <p>While reading <a href="http://thbecker.net/articles/rvalue_references/section_01.html">this explanation</a> on lvalues and rvalues, these lines of code stuck out to me:</p>
  
  <pre><code>int&amp; foo();
  foo() = 42; // OK, foo() is an lvalue
  </code></pre>
  
  <p>I tried it in g++, but the compiler says "undefined reference to foo()". If I add</p>
  
  <pre><code>int foo()
  {
    return 2;
  }
  
  int main()
  {
    int&amp; foo();
    foo() = 42;
  }
  </code></pre>
  
  <p>It compiles fine, but running it gives a <a href="http://en.wikipedia.org/wiki/Segmentation_fault">segmentation fault</a>. Just the line</p>
  
  <pre><code>int&amp; foo();
  </code></pre>
  
  <p>by itself both compiles and runs without any problems.</p>
  
  <p>What does this code mean? How can you assign a value to a function call, and why is it not an rvalue?</p>