[libcxx-commits] [PATCH] D94656: [libcxx testing] Fix UB in tests for std::lock_guard
Igor Kudrin via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jan 14 18:47:06 PST 2021
ikudrin updated this revision to Diff 316828.
ikudrin removed a project: LLVM.
ikudrin added a comment.
Trying to force CI to run.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94656/new/
https://reviews.llvm.org/D94656
Files:
libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
Index: libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
===================================================================
--- libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
+++ libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/mutex.pass.cpp
@@ -21,14 +21,20 @@
#include <cstdlib>
#include <cassert>
+#include "make_test_thread.h"
#include "test_macros.h"
std::mutex m;
+void do_try_lock() {
+ assert(m.try_lock() == false);
+}
+
int main(int, char**) {
{
std::lock_guard<std::mutex> lg(m);
- assert(m.try_lock() == false);
+ std::thread t = support::make_test_thread(do_try_lock);
+ t.join();
}
m.lock();
Index: libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
===================================================================
--- libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
+++ libcxx/test/std/thread/thread.mutex/thread.lock/thread.lock.guard/adopt_lock.pass.cpp
@@ -18,15 +18,21 @@
#include <cstdlib>
#include <cassert>
+#include "make_test_thread.h"
#include "test_macros.h"
std::mutex m;
+void do_try_lock() {
+ assert(m.try_lock() == false);
+}
+
int main(int, char**) {
{
m.lock();
std::lock_guard<std::mutex> lg(m, std::adopt_lock);
- assert(m.try_lock() == false);
+ std::thread t = support::make_test_thread(do_try_lock);
+ t.join();
}
m.lock();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94656.316828.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210115/d7d69e21/attachment-0001.bin>
More information about the libcxx-commits
mailing list