[libcxx-commits] [libcxx] [libc++] Don't try to wait on a thread that hasn't started in std::async, take 2 (PR #130145)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 25 08:31:54 PDT 2025


================
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// UNSUPPORTED: no-threads
+// UNSUPPORTED: c++03
+
+// This test uses std::atomic interfaces that are only available in C++20
+// UNSUPPORTED: c++11, c++14, c++17
+
+// Make sure that the `future` destructor keeps the data alive until the thread finished. This test fails by triggering
+// TSan. It may not be observable by normal means.
+
+#include <atomic>
+#include <future>
+#include <mutex>
+
+std::mutex mux;
+
+int main() {
----------------
ldionne wrote:

Nitpick:
```suggestion
int main(int, char**) {
```

https://github.com/llvm/llvm-project/pull/130145


More information about the libcxx-commits mailing list