[llvm-bugs] [Bug 41032] New: parameter passed to std::packaged_task byref stays wrapped with std::reference_wrapper

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 11 11:06:35 PDT 2019


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

            Bug ID: 41032
           Summary: parameter passed to std::packaged_task byref stays
                    wrapped with std::reference_wrapper
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kirshamir at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

auto task = std::packaged_task<int(const std::vector<int>&)>{
[] (const auto& vec) {
    // clang pass into the method std::reference_wrapper
    // correct behavior should be to unwrap it 
    return std::accumulate(vec.get().begin(), vec.get().end(), 0);
}};

// Code above works only because of the call to 'get' to retrieve the content
of the std::reference_wrapper

// Call the task with some std::vector<int> named vec:
std::thread t = std::thread(std::move(task), std::cref(vec));

Full code:
http://coliru.stacked-crooked.com/a/cc3b2c44ef5d9834

-- 
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/20190311/94e8db20/attachment-0001.html>


More information about the llvm-bugs mailing list