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

            Bug ID: 44540
           Summary: Inheriting from vector of move-only type leads to copy
                    constructor being used
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: we...@wsoptics.de
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

The following code does not compile with clang + libstdc++:

#include <vector>

struct MoveOnly
{
        MoveOnly() = default;
        MoveOnly(MoveOnly const &) = delete;
        MoveOnly(MoveOnly &&) = default;
        MoveOnly & operator=(MoveOnly const &) = delete;
        MoveOnly & operator=(MoveOnly &&) = default;
};

template <typename T>
class V : public std::vector<T>
{
        using std::vector<T>::vector;

        explicit V(std::vector<T> const & v) : std::vector<T>(v) {}

        explicit V(std::vector<T> && v) : std::vector<T>(std::move(v)) {}
};

void f()
{
        V<MoveOnly> v{};
}


It does however compile with gcc and also with clang + libc++.  (But then again
not with MSVC.)

I think there's no reason for the copy constructor to be used here though.

See also

https://godbolt.org/z/m_G99y

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to