Skip to content

Commit b30a1f3

Browse files
committed
Merge #18052: Remove false positive GCC warning
e9434ee Remove false positive GCC warning (Hennadii Stepanov) Pull request description: On master (f05c1ac) 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: ACK e9434ee, removes the warning for me (gcc 7.4.0) kristapsk: ACK e9434ee Tree-SHA512: 8820a8ba6a75aa6b1ac675a38c883a77f12968b010533b6383180aa66e7e0d570bf6300744903ead91cf9084e5345144959cd6b0cea1b763190b8dd49bacce75
2 parents c8ce263 + e9434ee commit b30a1f3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <interfaces/wallet.h>
1414
#include <key.h>
1515
#include <key_io.h>
16+
#include <optional.h>
1617
#include <policy/fees.h>
1718
#include <policy/policy.h>
1819
#include <primitives/block.h>
@@ -3910,7 +3911,8 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
39103911

39113912
// No need to read and scan block if block was created before
39123913
// our wallet birthday (as adjusted for block time variability)
3913-
Optional<int64_t> time_first_key;
3914+
// The way the 'time_first_key' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0.
3915+
Optional<int64_t> time_first_key = MakeOptional(false, int64_t());;
39143916
for (auto spk_man : walletInstance->GetAllScriptPubKeyMans()) {
39153917
int64_t time = spk_man->GetTimeFirstKey();
39163918
if (!time_first_key || time < *time_first_key) time_first_key = time;

0 commit comments

Comments
 (0)