<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Calling make_shared<int> with a unique_ptr<int>&& should not compile"
   href="http://llvm.org/bugs/show_bug.cgi?id=17295">17295</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Calling make_shared<int> with a unique_ptr<int>&& should not compile
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ali.baharev@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code compiles without any warning.

#include <iostream>
#include <memory>

int main()
{
   std::unique_ptr<int> u_ptr(new int(42));

   std::cout << " u_ptr.get() = " <<  u_ptr.get() << std::endl;
   std::cout << "*u_ptr       = " << *u_ptr       << std::endl;

   auto s_ptr = std::make_shared<int>(std::move(u_ptr));

   std::cout << "After move" << std::endl;

   std::cout << " u_ptr.get() = " <<  u_ptr.get() << std::endl;
   std::cout << "*u_ptr       = " << *u_ptr       << std::endl;
   std::cout << " s_ptr.get() = " <<  s_ptr.get() << std::endl;
   std::cout << "*s_ptr       = " << *s_ptr       << std::endl;
}

It prints:

 u_ptr.get() = 0x1a5c010
*u_ptr       = 42
After move
 u_ptr.get() = 0x1a5c010
*u_ptr       = 42
 s_ptr.get() = 0x1a5c048
*s_ptr       = 1

I believe the above code should not compile, int doesn't have ctor taking 
unique_ptr<int>&& as an argument. GCC 4.7.2 rejects the above code with the
following error:

/usr/include/c++/4.7/ext/new_allocator.h:110:4: error: invalid user-defined
conversion from ‘std::unique_ptr<int>’ to ‘int’ [-fpermissive]
In file included from /usr/include/c++/4.7/memory:86:0,
                 from ptr.cpp:2:
/usr/include/c++/4.7/bits/unique_ptr.h:233:16: note: candidate is:
std::unique_ptr<_Tp, _Dp>::operator bool() const [with _Tp = int; _Dp =
std::default_delete<int>] <near match>
/usr/include/c++/4.7/bits/unique_ptr.h:233:16: note:   return type ‘bool’ of
explicit conversion function cannot be converted to ‘int’ with a qualification
conversion</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>