From 4a9994931aba67fccb58bdef4b4361d2950c0c51 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 4 Dec 2022 10:24:28 -0800 Subject: [PATCH] Avoid double-move This was flagged by coverity but doesn't seem to be an actual issue in g++/clang. It technically leaves the moved rvalue in a "valid but undefined state", so it is best to avoid. The single copy into an lvalue is (I think) cheap --- thirdparty/thread-pool/bs_thread_pool.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/thirdparty/thread-pool/bs_thread_pool.hpp b/thirdparty/thread-pool/bs_thread_pool.hpp index cb6fe084a3..d1ef3a948d 100644 --- a/thirdparty/thread-pool/bs_thread_pool.hpp +++ b/thirdparty/thread-pool/bs_thread_pool.hpp @@ -405,8 +405,9 @@ public: blocks blks(first_index, index_after_last, num_blocks ? num_blocks : thread_count); if (blks.get_total_size() > 0) { + F internal_loop = loop; for (size_t i = 0; i < blks.get_num_blocks(); ++i) - push_task(std::forward(loop), blks.start(i), blks.end(i)); + push_task(std::forward(internal_loop), blks.start(i), blks.end(i)); } }