[libcxx] func.wrap.func.con: Unset function before destroying anything
authorVolodymyr Sapsai <vsapsai@apple.com>
Wed, 25 Apr 2018 23:38:41 +0000 (23:38 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Wed, 25 Apr 2018 23:38:41 +0000 (23:38 +0000)
commitaa208791bb950bd56f85eb200c7ac08df89b5efb
tree4aaa51fba1398c820d0c4d788a2bae4d390254db
parent2c6430fe3c2005a60680b72a52bfb4e81ca841ee
[libcxx] func.wrap.func.con: Unset function before destroying anything

Be defensive against a reentrant std::function::operator=(nullptr_t), in case
the held function object has a non-trivial destructor.  Destroying the function
object in-place can lead to the destructor being called twice.

Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai.

rdar://problem/32836603

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits, arphaman

Differential Revision: https://reviews.llvm.org/D34331

llvm-svn: 330885
libcxx/include/__functional_03
libcxx/include/functional
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp [new file with mode: 0644]
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp [new file with mode: 0644]