<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 --- - clang-cl doesn't accept two implicit conversions with a smart pointer pattern in the same way that MSVC does"
   href="http://llvm.org/bugs/show_bug.cgi?id=20821">20821</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-cl doesn't accept two implicit conversions with a smart pointer pattern in the same way that MSVC does
          </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>All
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ehsan@mozilla.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>$ cat test.cpp
template<class T>
struct SP {
  SP();
  SP(T*);
  void operator=(T*);
  operator T*();
};

struct B{};
struct D:B{};

void f() {
  SP<D> d;
  SP<B> b = d;
}

$ cl -c test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.61030 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.cpp

$ clang-cl -c test.cpp
test.cpp(14,9) :  error: no viable conversion from 'SP<D>' to 'SP<B>'
  SP<B> b = d;
        ^   ~
test.cpp(2,8) :  note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from 'SP<D>' to 'const SP<B> &' for 1st
      argument
struct SP {
       ^
test.cpp(2,8) :  note: candidate constructor (the implicit move constructor)
not viable: no known conversion from 'SP<D>' to 'SP<B> &&' for 1st argument

struct SP {
       ^
test.cpp(4,3) :  note: candidate constructor not viable: no known conversion
from 'SP<D>' to 'B *' for 1st argument
  SP(T*);
  ^
test.cpp(6,3) :  note: candidate function
  operator T*();
  ^
1 error generated.


It seems like MSVC first invokes SP::operator T*() and then invokes the ctor
taking the T* from it, which requires another implicit conversion from D* to
B*.  I don't think this is valid C++, but we may want to support it for compat
with MSVC.</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>