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

            Bug ID: 36703
           Summary: std::map copy assignment fails for mapped types
                    without copy assignment
           Product: libc++
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: plros...@gmail.com
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

I've noticed that a program I'm working on would compile with libstdc++ but not
with libc++. Here's a minimal version:

#include <map>

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

using MyMap = std::map<int, Mapped>;

int main()
{
    const MyMap map1{};
    MyMap map2{};
    map2 = map1;
    // this would work:
    // map2 = MyMap{map1};
    return 0;
}

clang 6 would complain:

/opt/clang-6.0.0/bin/../include/c++/v1/map:629:15: error: object of type
'std::__1::pair<int, Mapped>' cannot be assigned because its copy assignment
operator is implicitly deleted
        {__nc = __v.__cc; return *this;}

I see that a similar bug #23304 was closed as invalid. Still, I believe there
is a room for improvement here for libc++ to be a drop-in replacement for
libstdc++. Maybe there should be a fallback copy assignment implementation that
avoids using copy assignment for the mapped type.

I would have hard time explaining to my colleagues why I need to create a
temporary map object to placate libc++.

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

Reply via email to