Skip to content

Commit 4018e23

Browse files
committed
Merge bitcoin/bitcoin#23573: refactor: cast bool operands to int to silence compiler warning
ab22a71 refactor: cast bool to int to silence compiler warning (Jon Atack) Pull request description: This fixes a compiler warning: ``` node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical] return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning node/interfaces.cpp:544:16: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical] return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ && node/interfaces.cpp:544:16: note: cast one or both operands to int to silence this warning 2 warnings generated. ``` ACKs for top commit: sipa: utACK ab22a71 theStack: Concept and code-review ACK ab22a71 shaavan: ACK ab22a71 Tree-SHA512: 84e5aeabc1514a7586ac7c78a8eff1d15a5967dced7b2485b266b6fd79a530e1b22d99ded0a5df39f7806d3c5fd6d9752f08a722cc3be17850a6242c4022ab03
2 parents 95d19f8 + ab22a71 commit 4018e23

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/node/interfaces.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,11 @@ class ChainImpl : public Chain
540540
const CBlockIndex* block2 = m_node.chainman->m_blockman.LookupBlockIndex(block_hash2);
541541
const CBlockIndex* ancestor = block1 && block2 ? LastCommonAncestor(block1, block2) : nullptr;
542542
// Using & instead of && below to avoid short circuiting and leaving
543-
// output uninitialized.
544-
return FillBlock(ancestor, ancestor_out, lock, active) & FillBlock(block1, block1_out, lock, active) & FillBlock(block2, block2_out, lock, active);
543+
// output uninitialized. Cast bool to int to avoid -Wbitwise-instead-of-logical
544+
// compiler warnings.
545+
return int{FillBlock(ancestor, ancestor_out, lock, active)} &
546+
int{FillBlock(block1, block1_out, lock, active)} &
547+
int{FillBlock(block2, block2_out, lock, active)};
545548
}
546549
void findCoins(std::map<COutPoint, Coin>& coins) override { return FindCoins(m_node, coins); }
547550
double guessVerificationProgress(const uint256& block_hash) override

0 commit comments

Comments
 (0)