title: Initializing lvalue reference with rvalue
body: <p>I built this code with gcc/clang and got different results:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  
  int main() {
      std::istream&amp; is = 1 ? std::move(std::stringstream("")) : std::cin;
  }
  </code></pre>
  
  <ul>
  <li>Why gcc allows initializing lvalue reference with rvalue (<code>std::stringstream("")</code>)?</li>
  <li>Why clang tries to call copy constructor?</li>
  </ul>
  
  <h2>gcc 4.9.1</h2>
  
  <p>No error</p>
  
  <h2>clang 3.4</h2>
  
  <pre class="lang-none prettyprint-override"><code>prog.cc:5:63: error: call to implicitly-deleted copy constructor of 'istream' (aka 'basic_istream&lt;char&gt;')
      std::istream&amp; is = 1 ? std::move(std::stringstream("")) : std::cin;
                                                               ^~~~~~~~
  /usr/local/libcxx-3.4/include/c++/v1/istream:185:5: note: copy constructor is implicitly deleted because 'basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;' has a user-declared move constructor
     basic_istream(basic_istream&amp;&amp; __rhs);
     ^
  prog.cc:5:28: error: calling a protected constructor of class 'std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;'
     std::istream&amp; is = 1 ? std::move(std::stringstream("")) : std::cin;
                            ^
  /usr/local/libcxx-3.4/include/c++/v1/istream:185:5: note: declared protected here
     basic_istream(basic_istream&amp;&amp; __rhs);
     ^
  prog.cc:5:28: error: calling a protected constructor of class 'std::__1::basic_istream&lt;char, std::__1::char_traits&lt;char&gt; &gt;'
     std::istream&amp; is = 1 ? std::move(std::stringstream("")) : std::cin;
                            ^
  /usr/local/libcxx-3.4/include/c++/v1/istream:185:5: note: declared protected here
     basic_istream(basic_istream&amp;&amp; __rhs);
     ^
  </code></pre>