[llvm-bugs] [Bug 28096] New: Clang++ selects wrong constructor in return statement (lvalue instead of rvalue)

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 12 07:27:16 PDT 2016


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

            Bug ID: 28096
           Summary: Clang++ selects wrong constructor in return statement
                    (lvalue instead of rvalue)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stefan.walk+llvm at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Repro case below - if I read http://eel.is/c++draft/class.copy#32 correctly the
rvalue overload should be selected, but clang++ selects the lvalue one and
errors out. This is for example annoying when trying to return a local
unique_ptr to a derived class as a unique_ptr to the base class. G++ accepts
the code.

struct A {};
struct B {};

template <typename T>
struct X
{
    X() = default;

    template <typename bar>
    X(X<bar> const&) = delete;

    template <typename bar>
    X(X<bar>&&) {}
};

X<A> f()
{
    X<B> x;
    return x;
}

-- 
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/20160612/933334b1/attachment.html>


More information about the llvm-bugs mailing list