//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // class function // function& operator=(function &&); #include #include #include "test_macros.h" struct A { static std::function global; static bool cancel; ~A() { DoNotOptimize(cancel); if (cancel) global = std::function(nullptr); } void operator()() {} }; std::function A::global; bool A::cancel = false; int main() { A::global = A(); assert(A::global.target()); // Check that we don't recurse in A::~A(). A::cancel = true; A::global = std::function(nullptr); assert(!A::global.target()); }