title: Returning local unique_ptr as a shared_ptr
body: <p>I'm used to not use <code>std::move</code> when returning a <code>std::unique_ptr</code>, because doing so prohibits RVO. I have this case where I have a local <code>std::unique_ptr</code>, but the return type is a <code>std::shared_ptr</code>.
  Here's a sample of the code:</p>
  
  <pre><code>shared_ptr&lt;int&gt; getInt1() {
      auto i = make_unique&lt;int&gt;();
  
      *i = 1;
  
      return i;
  }
  
  shared_ptr&lt;int&gt; getInt2() {
      return make_unique&lt;int&gt;(2);
  }
  
  unique_ptr&lt;int&gt; getInt3() {
      auto ptr = make_unique&lt;int&gt;(2);
  
      return ptr;
  }
  
  int main() {
      cout &lt;&lt; *getInt1() &lt;&lt; endl &lt;&lt; *getInt2() &lt;&lt; *getInt3() &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>GCC accepts both cases, but Clang refuses the <code>getInt1()</code> With this error:</p>
  
  <pre><code>main.cpp:10:13: error: no viable conversion from 'std::unique_ptr&lt;int, std::default_delete&lt;int&gt; &gt;' to 'shared_ptr&lt;int&gt;'
      return i;
             ^
  </code></pre>
  
  <p>Here's both cases on coliru: <a href="http://coliru.stacked-crooked.com/a/58b889ffc9495cec" rel="nofollow">GCC</a>, <a href="http://coliru.stacked-crooked.com/a/9ea02839b2557d57" rel="nofollow">Clang</a></p>
  
  <p>Both compiler accept the third case.</p>
  
  <p>Which one is wrong? Thanks.</p>