diff options
author | fanquake <fanquake@gmail.com> | 2022-02-23 11:06:36 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-02-23 11:19:02 +0000 |
commit | 16d05cf6b9187fc47bab446a533ea140fe32b8e2 (patch) | |
tree | 73c09d744951e50f310bf5bbcae6ad8ccfb097ef | |
parent | b6a2670e29786db8a4555d17c2667bbc4ee08fd7 (diff) | |
parent | fafc4eb3637be0a85644c89c355fe68678a62c17 (diff) |
Merge bitcoin/bitcoin#24406: test: Fix Wambiguous-reversed-operator compiler warnings
fafc4eb3637be0a85644c89c355fe68678a62c17 test: Fix Wambiguous-reversed-operator compiler warnings (MarcoFalke)
Pull request description:
Add a missing const to avoid the C++20 clang **compiler warning**:
```
test/fuzz/addrman.cpp:325:22: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'AddrManDeterministic' and 'AddrManDeterministic') to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
assert(addr_man1 == addr_man2);
~~~~~~~~~ ^ ~~~~~~~~~
/usr/include/assert.h:93:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
test/fuzz/addrman.cpp:140:10: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
bool operator==(const AddrManDeterministic& other)
^
1 error generated.
```
This patch also fixes the **compile error** if the first operand is `const`:
```
test/fuzz/addrman.cpp:326:23: error: invalid operands to binary expression ('const AddrManDeterministic' and 'AddrManDeterministic')
assert(addr_man_1 == addr_man2);
~~~~~~~~~~ ^ ~~~~~~~~~
/usr/include/assert.h:90:27: note: expanded from macro 'assert'
(static_cast <bool> (expr) \
^~~~
test/fuzz/addrman.cpp:140:10: note: candidate function not viable: 'this' argument has type 'const AddrManDeterministic', but method is not marked const
bool operator==(const AddrManDeterministic& other)
^
1 error generated.
ACKs for top commit:
hebasto:
ACK fafc4eb3637be0a85644c89c355fe68678a62c17, I have reviewed the code and it looks OK, I agree it can be merged.
Tree-SHA512: 92cd62ae06ee1393a6dc2ea6f3f553595a8f8d66f51592d231b42122bfb71ed4801a016daafc85360040339c5ae59b76888265cec37449c4688d6c7768f4567e
-rw-r--r-- | src/test/fuzz/addrman.cpp | 2 | ||||
-rw-r--r-- | src/test/serialize_tests.cpp | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 3699abb597..ba917dec2a 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -137,7 +137,7 @@ public: * - vvNew entries refer to the same addresses * - vvTried entries refer to the same addresses */ - bool operator==(const AddrManDeterministic& other) + bool operator==(const AddrManDeterministic& other) const { LOCK2(m_impl->cs, other.m_impl->cs); diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 2441847f99..8c7c650cb1 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -38,13 +38,13 @@ public: READWRITE(obj.txval); } - bool operator==(const CSerializeMethodsTestSingle& rhs) + bool operator==(const CSerializeMethodsTestSingle& rhs) const { - return intval == rhs.intval && \ - boolval == rhs.boolval && \ - stringval == rhs.stringval && \ - strcmp(charstrval, rhs.charstrval) == 0 && \ - *txval == *rhs.txval; + return intval == rhs.intval && + boolval == rhs.boolval && + stringval == rhs.stringval && + strcmp(charstrval, rhs.charstrval) == 0 && + *txval == *rhs.txval; } }; |