1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // Windows cannot detect the deadlock. Instead of throwing system_error,
10 // it would dead lock the test
11 // UNSUPPORTED: windows
13 // TSAN bug: https://github.com/llvm/llvm-project/issues/66537
16 // UNSUPPORTED: no-threads
17 // UNSUPPORTED: no-exceptions
18 // UNSUPPORTED: c++03, c++11, c++14, c++17
19 // XFAIL: availability-synchronization_library-missing
28 #include <system_error>
30 #include <type_traits>
33 #include "make_test_thread.h"
34 #include "test_macros.h"
36 int main(int, char**) {
37 // resource_deadlock_would_occur - if deadlock is detected or get_id() == this_thread::get_id().
39 std::function
<void()> f
;
40 std::atomic_bool start
= false;
41 std::atomic_bool done
= false;
43 std::jthread jt
= support::make_test_jthread([&] {
54 } catch (const std::system_error
& err
) {
55 assert(err
.code() == std::errc::resource_deadlock_would_occur
);