title: Why rvalue reference binding to xvalue doesn't work in my code?
body: <p>I tried to understand lvalue and rvalue in C++11. So I wrote a test code:</p>
  
  <pre><code>int x = 10;
  int foo() { return x; }
  int&amp; bar() { return x; }
  int&amp;&amp; baz() { return 10; }
  
  int main() {
      int&amp; lr1 = 10;     // error: lvalue references rvalue
      int&amp; lr2 = x;      // ok
      int&amp; lr3 = foo();  // error: lvalue references rvalue
      int&amp; lr4 = bar();  // ok
      int&amp; lr5 = baz();  // error: lvalue references rvalue
  
      int&amp;&amp; rr1 = 10;    // ok
      int&amp;&amp; rr2 = x;     // error: rvalue references lvalue
      int&amp;&amp; rr3 = foo(); // ok
      int&amp;&amp; rr4 = bar(); // error: rvalue references lvalue
      int&amp;&amp; rr5 = baz(); // ok
  }
  </code></pre>
  
  <p>It works pretty well, so I inserted std::cout to print results.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int x= 10;
  int foo() { return x; }
  int&amp; bar() { return x; }
  int&amp;&amp; baz() { return 10; }
  
  int main() {
      int&amp; lr1 = 10;     std::cout &lt;&lt; lr1 &lt;&lt; std::endl; // error
      int&amp; lr2 = x;      std::cout &lt;&lt; lr2 &lt;&lt; std::endl; // ok
      int&amp; lr3 = foo();  std::cout &lt;&lt; lr3 &lt;&lt; std::endl; // error
      int&amp; lr4 = bar();  std::cout &lt;&lt; lr4 &lt;&lt; std::endl; // ok
      int&amp; lr5 = baz();  std::cout &lt;&lt; lr5 &lt;&lt; std::endl; // error
  
      int&amp;&amp; rr1 = 10;    std::cout &lt;&lt; rr1 &lt;&lt; std::endl; // ok
      int&amp;&amp; rr2 = x;     std::cout &lt;&lt; rr2 &lt;&lt; std::endl; // error
      int&amp;&amp; rr3 = foo(); std::cout &lt;&lt; rr3 &lt;&lt; std::endl; // ok
      int&amp;&amp; rr4 = bar(); std::cout &lt;&lt; rr4 &lt;&lt; std::endl; // error
      int&amp;&amp; rr5 = baz(); std::cout &lt;&lt; rr5 &lt;&lt; std::endl; // ERROR!?
  }
  </code></pre>
  
  <p><code>int&amp;&amp; rr5 = baz(); std::cout &lt;&lt; rr5;</code> causes a Runtime Error, but I don't know why it makes an error.</p>
  
  <p>I think the return value of <code>baz()</code> would be xvalue, so its lifetime is prolonged. But when I tried to access its value, the error occurs. Why?</p>