[libcxx-commits] [PATCH] D100277: [libc++] [test] Detect an improperly noexcept'ed __decay_copy.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 11 15:42:15 PDT 2021
Quuxplusone created this revision.
Quuxplusone added reviewers: cjdb, libc++, ldionne.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
`__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.)
(This came out of review comments on D100255 <https://reviews.llvm.org/D100255>.)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100277
Files:
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===================================================================
--- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ 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,7 +52,7 @@
bool f_run = false;
-void f()
+void f(const std::vector<int>&)
{
f_run = true;
}
@@ -125,9 +126,10 @@
void test_throwing_new_during_thread_creation() {
#ifndef TEST_HAS_NO_EXCEPTIONS
+ std::vector<int> v(10);
throw_one = 0xFFF;
{
- std::thread t(f);
+ std::thread t(f, v);
t.join();
}
numAllocs = 0xFFF - throw_one;
@@ -137,7 +139,7 @@
f_run = false;
unsigned old_outstanding = outstanding_new;
try {
- std::thread t(f);
+ std::thread t(f, v);
assert(i == numAllocs); // Only final iteration will not throw.
t.join();
assert(f_run);
@@ -156,7 +158,8 @@
{
test_throwing_new_during_thread_creation();
{
- std::thread t(f);
+ std::vector<int> v(10);
+ std::thread t(f, v);
t.join();
assert(f_run == true);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100277.336708.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210411/ec7b2008/attachment-0001.bin>
More information about the libcxx-commits
mailing list