https://bugs.llvm.org/show_bug.cgi?id=33125
Bug ID: 33125
Summary: std::function copies movable objects when is SOO is
used
Product: libc++
Version: 3.7
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: kiber...@yandex-team.ru
CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
Created attachment 18487
--> https://bugs.llvm.org/attachment.cgi?id=18487&action=edit
Test case
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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs