[llvm-bugs] [Bug 31051] New: __compressed_pair doesn't correctly forward constructor arguments.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 17 19:01:02 PST 2016


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: unassignedclangbugs at nondot.org
          Reporter: eric at efcs.ca
                CC: llvm-bugs at lists.llvm.org, mclow.lists at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161118/1c712c52/attachment.html>


More information about the llvm-bugs mailing list