15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 35a83710eSEric Fiselier // The LLVM Compiler Infrastructure 45a83710eSEric Fiselier // 55a83710eSEric Fiselier // This file is dual licensed under the MIT and the University of Illinois Open 65a83710eSEric Fiselier // Source Licenses. See LICENSE.TXT for details. 75a83710eSEric Fiselier // 85a83710eSEric Fiselier //===----------------------------------------------------------------------===// 95a83710eSEric Fiselier // 105a83710eSEric Fiselier // UNSUPPORTED: libcpp-has-no-threads 11*abd52cadSEric Fiselier // UNSUPPORTED: c++98, c++03 125a83710eSEric Fiselier 135a83710eSEric Fiselier // NOTE: std::terminate is called so the destructors are not invoked and the 145a83710eSEric Fiselier // memory is not freed. This will cause ASAN to fail. 155a83710eSEric Fiselier // XFAIL: asan 165a83710eSEric Fiselier 179a37bc91SEric Fiselier // NOTE: TSAN will report this test as leaking a thread. 189a37bc91SEric Fiselier // XFAIL: tsan 199a37bc91SEric Fiselier 205a83710eSEric Fiselier // <thread> 215a83710eSEric Fiselier 225a83710eSEric Fiselier // class thread 235a83710eSEric Fiselier 245a83710eSEric Fiselier // thread& operator=(thread&& t); 255a83710eSEric Fiselier 265a83710eSEric Fiselier #include <thread> 275a83710eSEric Fiselier #include <exception> 285a83710eSEric Fiselier #include <cstdlib> 295a83710eSEric Fiselier #include <cassert> 305a83710eSEric Fiselier 315a83710eSEric Fiselier class G 325a83710eSEric Fiselier { 335a83710eSEric Fiselier int alive_; 345a83710eSEric Fiselier public: 355a83710eSEric Fiselier static int n_alive; 365a83710eSEric Fiselier static bool op_run; 375a83710eSEric Fiselier 385a83710eSEric Fiselier G() : alive_(1) {++n_alive;} 395a83710eSEric Fiselier G(const G& g) : alive_(g.alive_) {++n_alive;} 405a83710eSEric Fiselier ~G() {alive_ = 0; --n_alive;} 415a83710eSEric Fiselier 42*abd52cadSEric Fiselier 435a83710eSEric Fiselier 445a83710eSEric Fiselier void operator()(int i, double j) 455a83710eSEric Fiselier { 465a83710eSEric Fiselier assert(alive_ == 1); 475a83710eSEric Fiselier assert(n_alive >= 1); 485a83710eSEric Fiselier assert(i == 5); 495a83710eSEric Fiselier assert(j == 5.5); 505a83710eSEric Fiselier op_run = true; 515a83710eSEric Fiselier } 525a83710eSEric Fiselier }; 535a83710eSEric Fiselier 545a83710eSEric Fiselier int G::n_alive = 0; 555a83710eSEric Fiselier bool G::op_run = false; 565a83710eSEric Fiselier 575a83710eSEric Fiselier void f1() 585a83710eSEric Fiselier { 59*abd52cadSEric Fiselier std::_Exit(0); 605a83710eSEric Fiselier } 615a83710eSEric Fiselier 625a83710eSEric Fiselier int main() 635a83710eSEric Fiselier { 645a83710eSEric Fiselier std::set_terminate(f1); 655a83710eSEric Fiselier { 669a37bc91SEric Fiselier G g; 679a37bc91SEric Fiselier std::thread t0(g, 5, 5.5); 685a83710eSEric Fiselier std::thread::id id = t0.get_id(); 695a83710eSEric Fiselier std::thread t1; 705a83710eSEric Fiselier t0 = std::move(t1); 715a83710eSEric Fiselier assert(false); 725a83710eSEric Fiselier } 735a83710eSEric Fiselier } 74