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 
11 // UNSUPPORTED: libcpp-no-exceptions
12 // UNSUPPORTED: libcpp-has-no-threads
13 // UNSUPPORTED: c++98, c++03
14 
15 // <future>
16 
17 // class promise<R>
18 
19 // void set_exception(exception_ptr p);
20 // Test that a null exception_ptr is diagnosed.
21 
22 #define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
23 
24 #define _LIBCPP_DEBUG 0
25 #include <future>
26 #include <exception>
27 #include <cstdlib>
28 #include <cassert>
29 
30 
main()31 int main()
32 {
33     {
34         typedef int T;
35         std::promise<T> p;
36         try {
37             p.set_exception(std::exception_ptr());
38             assert(false);
39         } catch (int const& value) {
40             assert(value == 42);
41         }
42     }
43     {
44         typedef int& T;
45         std::promise<T> p;
46         try {
47             p.set_exception(std::exception_ptr());
48             assert(false);
49         } catch (int const& value) {
50             assert(value == 42);
51         }
52     }
53 }
54