[llvm-bugs] [Bug 37722] New: The conversion is not fully fixed?

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 6 18:20:41 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37722

            Bug ID: 37722
           Summary: The conversion is not fully fixed?
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

template<typename T>
class Thing { };

template<typename T>
class Wrapper {
    Thing<T> value;

public:
    // If you remove 'explicit', type deduction is performed correctly
    explicit operator auto() const {
        return value;
    }
};

int main() {
    Wrapper<int> a;
    auto a_view = static_cast<Thing<int>>(a);
    return 0;
}

clang++ produces the following messages:

error: 
      no matching conversion for static_cast from 'Wrapper<int>' to
'Thing<int>'
    auto a_view = static_cast<Thing<int>>(a);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note: 
      candidate constructor (the implicit copy constructor) not viable: no
known
      conversion from 'Wrapper<int>' to 'const Thing<int>' for 1st argument
class Thing { };
      ^
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note: 
      candidate constructor (the implicit move constructor) not viable: no
known
      conversion from 'Wrapper<int>' to 'Thing<int>' for 1st argument
class Thing { };
      ^
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note: 
      candidate constructor (the implicit default constructor) not viable:
      requires 0 arguments, but 1 was provided
1 error generated.

The above code compiles fine with g++. The code sample comes from
https://bugs.llvm.org/show_bug.cgi?id=35466. It reports similar problems.
Perhaps, the reported bug is not fully fixed?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180607/cc3b94cb/attachment-0001.html>


More information about the llvm-bugs mailing list