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

            Bug ID: 31051
           Summary: __compressed_pair doesn't correctly forward
                    constructor arguments.
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: e...@efcs.ca
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
    Classification: Unclassified

__compressed_pair takes it's arguments by value, which incurs an additional
copy or move. This needs to be fixed.

Reproducer:

#include <memory>
#include <cassert>
int A_moved = 0;
struct A {
  A() = default;
  A(A const&) = default;
  A(A&&) { ++A_moved; };
};

int main() {
  std::__compressed_pair<A, int> p(A{});
  assert(A_moved == 3); // Assert passes
  assert(A_moved == 1); // Assert fails
}

-- 
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