Skip to content

False positive -Wmaybe-uninitialized warning of GCC 10.2 #21318

@hebasto

Description

@hebasto

On the master (e52ce9f):

$ ./configure CC=gcc-10 CXX=g++-10
$ make clean > /dev/null
$ make > /dev/null
txmempool.cpp: In member function ‘CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>&) const’:
txmempool.cpp:894:29: warning: ‘<anonymous>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  894 |     return Optional<txiter>{};
      |                             ^

The following patch

--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -891,7 +891,7 @@ Optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
 {
     auto it = mapTx.find(txid);
     if (it != mapTx.end()) return it;
-    return Optional<txiter>{};
+    return {};
 }
 
 CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const

doesn't help.


System:

$ lsb_release -dc
Description:	Linux Mint 20.1
Codename:	ulyssa
$ g++-10 --version | grep g++
g++-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions