mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Merge #18052: Remove false positive GCC warning
e9434ee03e
Remove false positive GCC warning (Hennadii Stepanov) Pull request description: On master (f05c1ac444
) GCC compiler fires a false positive `-Wmaybe-uninitialized`: ``` wallet/wallet.cpp: In static member function ‘static std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain&, const WalletLocation&, std::__cxx11::string&, std::vector<std::__cxx11::basic_string<char> >&, uint64_t)’: wallet/wallet.cpp:3913:27: warning: ‘*((void*)& time_first_key +8)’ may be used uninitialized in this function [-Wmaybe-uninitialized] Optional<int64_t> time_first_key; ^~~~~~~~~~~~~~ ``` The same as #15292. This PR leverages a workaround and removes the warning. ACKs for top commit: laanwj: ACKe9434ee03e
, removes the warning for me (gcc 7.4.0) kristapsk: ACKe9434ee03e
Tree-SHA512: 8820a8ba6a75aa6b1ac675a38c883a77f12968b010533b6383180aa66e7e0d570bf6300744903ead91cf9084e5345144959cd6b0cea1b763190b8dd49bacce75
This commit is contained in:
commit
b30a1f3e39
1 changed files with 3 additions and 1 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <interfaces/wallet.h>
|
||||
#include <key.h>
|
||||
#include <key_io.h>
|
||||
#include <optional.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/policy.h>
|
||||
#include <primitives/block.h>
|
||||
|
@ -3910,7 +3911,8 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
|||
|
||||
// No need to read and scan block if block was created before
|
||||
// our wallet birthday (as adjusted for block time variability)
|
||||
Optional<int64_t> time_first_key;
|
||||
// The way the 'time_first_key' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
|
||||
Optional<int64_t> time_first_key = MakeOptional(false, int64_t());;
|
||||
for (auto spk_man : walletInstance->GetAllScriptPubKeyMans()) {
|
||||
int64_t time = spk_man->GetTimeFirstKey();
|
||||
if (!time_first_key || time < *time_first_key) time_first_key = time;
|
||||
|
|
Loading…
Add table
Reference in a new issue