1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // UNSUPPORTED: libcpp-has-no-threads
11 
12 // <future>
13 
14 // class promise<R>
15 
16 // void promise::set_exception_at_thread_exit(exception_ptr p);
17 
18 #include <future>
19 #include <cassert>
20 
func(std::promise<int> p)21 void func(std::promise<int> p)
22 {
23     const int i = 5;
24     p.set_exception_at_thread_exit(std::make_exception_ptr(3));
25 }
26 
main()27 int main()
28 {
29     {
30         typedef int T;
31         std::promise<T> p;
32         std::future<T> f = p.get_future();
33         std::thread(func, std::move(p)).detach();
34         try
35         {
36             f.get();
37             assert(false);
38         }
39         catch (int i)
40         {
41             assert(i == 3);
42         }
43     }
44 }
45