diff --git a/src/optional.h b/src/optional.h --- a/src/optional.h +++ b/src/optional.h @@ -5,11 +5,18 @@ #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 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1939,9 +1939,11 @@ auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); - // Height of the specified block or the common ancestor, if the block - // provided was in a deactivated chain. - Optional height; + // The way the 'height' is initialized is just a workaround for the gcc bug + // #47679 since version 4.6.0. Height of the specified block or the common + // ancestor, if the block provided was in a deactivated chain. + Optional height = MakeOptional(false, int()); + // Height of the specified block, even if it's in a deactivated chain. Optional altheight; int target_confirms = 1; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1851,7 +1851,9 @@ ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), 0); BlockHash 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; {