diff --git a/src/optional.h b/src/optional.h index 1614c8971836d..95a3b24d0a027 100644 --- a/src/optional.h +++ b/src/optional.h @@ -5,12 +5,21 @@ #ifndef BITCOIN_OPTIONAL_H #define BITCOIN_OPTIONAL_H +#include + #include //! Substitute for C++17 std::optional template using Optional = boost::optional; +//! Substitute for C++17 std::make_optional +template +Optional MakeOptional(bool condition, T&& value) +{ + return boost::make_optional(condition, std::forward(value)); +} + //! Substitute for C++17 std::nullopt static auto& nullopt = boost::none; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c439418886ea2..c0e40e9b4a4eb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1656,7 +1656,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request) LockAnnotation lock(::cs_main); LOCK(pwallet->cs_wallet); - Optional height; // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain. + // The way the 'height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0. + Optional height = MakeOptional(false, int()); // Height of the specified block or the common ancestor, if the block provided was in a deactivated chain. Optional altheight; // Height of the specified block, even if it's in a deactivated chain. int target_confirms = 1; isminefilter filter = ISMINE_SPENDABLE; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c7b82cf6e40f2..5c886230e9971 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2182,7 +2182,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc fAbortRescan = false; ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup uint256 tip_hash; - Optional block_height; + // The way the 'block_height' is initialized is just a workaround for the gcc bug #47679 since version 4.6.0. + Optional block_height = MakeOptional(false, int()); double progress_begin; double progress_end; {