Skip to content

Commit ff9c671

Browse files
ryanofskylaanwj
authored andcommitted
refactor: Work around GCC 9 -Wredundant-move warning
Use std::move workaround for unique_ptr, for when the C++ compiler lacks a fix for this issue: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 Do this in a way that avoids a GCC 9 `-Wredundant-move` warning.
1 parent b837b33 commit ff9c671

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/interfaces/chain.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,10 @@ class ChainImpl : public Chain
236236
explicit ChainImpl(NodeContext& node) : m_node(node) {}
237237
std::unique_ptr<Chain::Lock> lock(bool try_lock) override
238238
{
239-
auto result = MakeUnique<LockImpl>(::cs_main, "cs_main", __FILE__, __LINE__, try_lock);
240-
if (try_lock && result && !*result) return {};
241-
// std::move necessary on some compilers due to conversion from
242-
// LockImpl to Lock pointer
243-
return std::move(result);
239+
auto lock = MakeUnique<LockImpl>(::cs_main, "cs_main", __FILE__, __LINE__, try_lock);
240+
if (try_lock && lock && !*lock) return {};
241+
std::unique_ptr<Chain::Lock> result = std::move(lock); // Temporary to avoid CWG 1579
242+
return result;
244243
}
245244
bool findBlock(const uint256& hash, CBlock* block, int64_t* time, int64_t* time_max) override
246245
{

0 commit comments

Comments
 (0)