[libcxx-commits] [libcxx] d7eb797 - [libc++] [test] Detect an improperly noexcept'ed __decay_copy.

Arthur O'Dwyer via libcxx-commits libcxx-commits at lists.llvm.org
Mon Apr 12 09:28:31 PDT 2021


Author: Arthur O'Dwyer
Date: 2021-04-12T12:28:01-04:00
New Revision: d7eb797ea55c76c7a71886343e216be27d5757be

URL: https://github.com/llvm/llvm-project/commit/d7eb797ea55c76c7a71886343e216be27d5757be
DIFF: https://github.com/llvm/llvm-project/commit/d7eb797ea55c76c7a71886343e216be27d5757be.diff

LOG: [libc++] [test] Detect an improperly noexcept'ed __decay_copy.

`__decay_copy` is used by `std::thread`'s constructor to copy its arguments
into the new thread. If `__decay_copy` claims to be noexcept, but then
copying the argument does actually throw, we'd call std::terminate instead
of passing this test. (And I've verified that adding an unconditional `noexcept`
to `__decay_copy` does indeed fail this test.)

Differential Revision: https://reviews.llvm.org/D100277

Added: 
    

Modified: 
    libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
index 64bbe1b941a7..02f19a0b11a0 100644
--- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -23,6 +23,7 @@
 #include <atomic>
 #include <cstdlib>
 #include <cassert>
+#include <vector>
 
 #include "test_macros.h"
 
@@ -51,10 +52,12 @@ void  operator delete(void* p) TEST_NOEXCEPT
 
 bool f_run = false;
 
-void f()
-{
-    f_run = true;
-}
+struct F {
+    std::vector<int> v_;  // so f's copy-ctor calls operator new
+    explicit F() : v_(10) {}
+    void operator()() const { f_run = true; }
+};
+F f;
 
 class G
 {


        


More information about the libcxx-commits mailing list