xref: /llvm-project/libcxx/test/std/atomics/atomics.types.generic/throw.pass.cpp (revision 92832e4889ae6038cc8b3e6e449af2a9b9374ab4)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: no-exceptions
11 
12 // <atomic>
13 
14 #include <atomic>
15 #include <cassert>
16 
17 struct throwing {
throwingthrowing18   throwing() { throw 42; }
19 };
20 
main(int,char **)21 int main(int, char**) {
22   try {
23     [[maybe_unused]] std::atomic<throwing> a;
24     assert(false);
25   } catch (int x) {
26     assert(x == 42);
27   }
28 
29   return 0;
30 }
31