aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/thread
diff options
context:
space:
mode:
authorPaul Scharnofske <asynts@gmail.com>2020-11-11 09:29:37 +0000
committerJonathan Wakely <jwakely@redhat.com>2020-11-11 11:13:31 +0000
commit0ebaea3b6677ef8edfa5638800304db1a4f7c2f8 (patch)
tree76e8e5d3415c5a0039034cd4f5ad249032996a4a /libstdc++-v3/include/std/thread
parent43f9e5aff06f1ca2296fdbd3141fe90ec0be1912 (diff)
downloadgcc-0ebaea3b6677ef8edfa5638800304db1a4f7c2f8.zip
gcc-0ebaea3b6677ef8edfa5638800304db1a4f7c2f8.tar.gz
gcc-0ebaea3b6677ef8edfa5638800304db1a4f7c2f8.tar.bz2
libstdc++: Assigning to a joinable std::jthread calls std::terminate
Move assigning to a std::jthread that represents a thread of execution needs to send a stop request and join that running thread. Otherwise the std::thread data member will terminate in its assignment operator. Co-authored-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/thread (jthread::operator=(jthread&&)): Transfer any existing state to a temporary that will request a stop and then join. * testsuite/30_threads/jthread/jthread.cc: Test move assignment.
Diffstat (limited to 'libstdc++-v3/include/std/thread')
-rw-r--r--libstdc++-v3/include/std/thread6
1 files changed, 5 insertions, 1 deletions
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index 887ee57..080036e 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -456,7 +456,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator=(const jthread&) = delete;
jthread&
- operator=(jthread&&) noexcept = default;
+ operator=(jthread&& __other) noexcept
+ {
+ std::jthread(std::move(__other)).swap(*this);
+ return *this;
+ }
void
swap(jthread& __other) noexcept