Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,16 @@ namespace {
class ScopedBLSLegacyScheme
{
public:
explicit ScopedBLSLegacyScheme(std::optional<bool> 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 :

@knst knst Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE FOR REVIEWERS:
that is silly fix but it is required because false-alarm in gcc

See relevant changes in mainstream Bitcoin Core:

commit 5294f0d5a94cc7beaf692131fba0cad8beec9f13
Author: fanquake <fanquake@gmail.com>
Date:   Mon Mar 22 11:22:06 2021 +0800

    refactor: return std::nullopt instead of {}

    In #21415 we decided to return `std::optional` rather than `{}` for
    uninitialized values. This PR repalces the two remaining usages of `{}`
    with `std::nullopt`.

    As a side-effect, this also quells the spurious GCC 10.2.x warning that
    we've had reported quite a few times. i.e #21318, #21248, #20797.

    ```bash
    txmempool.cpp: In member function 'CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>&) const':
    txmempool.cpp:898:13: warning: '<anonymous>' may be used uninitialized in this function [-Wmaybe-uninitialized]
      898 |     return {};
          |             ^

It's false alarm in gcc, so, std::optional should not be default initialized to avoid warnings.

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
Expand Down
Loading