From 0d092f5813f1b074ce6382a71da8c4d3c095ecb2 Mon Sep 17 00:00:00 2001 From: pasta Date: Wed, 12 Aug 2026 14:11:42 -0500 Subject: [PATCH] fix: avoid maybe-uninitialized warning in ScopedBLSLegacyScheme GCC 14 at -O2 (the nowallet CI job) rejects the std::optional constructor parameter with -Werror=maybe-uninitialized when the guard is default-constructed: the inliner loses track of the has_value() check guarding the payload read. Replace the optional parameter with a default constructor and an explicit bool constructor; both existing value-passing call sites already pass a plain bool, so no caller changes. --- src/validation.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 5b1e8924d8c4..2d5f23772751 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -161,12 +161,16 @@ namespace { class ScopedBLSLegacyScheme { public: - explicit ScopedBLSLegacyScheme(std::optional enter = std::nullopt) noexcept : + ScopedBLSLegacyScheme() noexcept : m_saved(bls::bls_legacy_scheme.load()) { - if (enter.has_value() && *enter != m_saved) { - bls::bls_legacy_scheme.store(*enter); - LogPrintf("ScopedBLSLegacyScheme: entered bls_legacy_scheme=%d\n", *enter); + } + explicit ScopedBLSLegacyScheme(bool enter) noexcept : + m_saved(bls::bls_legacy_scheme.load()) + { + if (enter != m_saved) { + bls::bls_legacy_scheme.store(enter); + LogPrintf("ScopedBLSLegacyScheme: entered bls_legacy_scheme=%d\n", enter); } } ~ScopedBLSLegacyScheme() noexcept