http://llvm.org/bugs/show_bug.cgi?id=20821

            Bug ID: 20821
           Summary: clang-cl doesn't accept two implicit conversions with
                    a smart pointer pattern in the same way that MSVC does
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

$ 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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to