[llvm-bugs] [Bug 33125] New: std::function copies movable objects when is SOO is used
llvm-bugs at lists.llvm.org
Mon May 22 08:56:43 PDT 2017
Bug ID: 33125
Summary: std::function copies movable objects when is SOO is
OS: MacOS X
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: kibergus at yandex-team.ru
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Created attachment 18487
Hi. Libc++ that comes with Xcode 8.2.1 has small object optimization
implemented for std::function. But move constructor of std::function always
uses copy constructor of the object. This results in unnecessary copies being
made and additional destructor calls.
In our use case this even leads to crashes because the object is a handle and
we rely that it will be destroyed on specific thread. But that extra copies,
created while the std::function is dispatched to the worker thread, result in
destructor being deleted at another time and from another thread.
It would be good if moving std::function object resulted in moving the
underlying functor if it is movable.
I've attached a test program, that demonstrates the problem.
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-bugs