[LLVMbugs] [Bug 11309] New: move constructor does not suppress copy constructor

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Nov 4 06:42:12 PDT 2011


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

             Bug #: 11309
           Summary: move constructor does not suppress copy constructor
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++0x
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chris at bubblescope.net
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following code is used in g++'s std::shared_ptr, which currently does not
build with clang (at least in g++ 4.6.2).

The following code compiles in g++, but not in clang++. g++'s reasoning is (I
think):

1) The T(T&&) constructor stops automatic generation of the copy constructor.
2) When looking for a copy constructor, use the templated one.

However, this an area I feel a bit dodgy on, I lost track of how the rules were
changing as the standard was finalised.

Looking at the most recent draft I have access to (n3242), shared_ptr should
have a constructor:

shared_ptr(const shared_ptr& r) noexcept;

which g++ seems to be currently missing, and would clean this problem up.

struct S
{
    S(const S&) = delete;
    S() {};
};

template<typename X>
struct T : public S
{
    template<typename _Tp1>
    T(const T<_Tp1>& __r) { }

    T(T&&) { }

    T() {}
};

int main(void)
{
    T<int> i;
    T<int> j(i);
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list