test: Fix Wambiguous-reversed-operator compiler warnings #24406

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2202-cpp20compw-💚 changing 2 files +7 −7
  1. MarcoFalke commented at 3:42 PM on February 21, 2022: member

    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.
    
  2. test: Fix Wambiguous-reversed-operator compiler warnings fafc4eb363
  3. DrahtBot added the label Tests on Feb 21, 2022
  4. DrahtBot commented at 7:44 PM on February 21, 2022: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24169 (build: Add --enable-c++20 option by MarcoFalke)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. hebasto approved
  6. hebasto commented at 9:51 PM on February 22, 2022: member

    ACK fafc4eb3637be0a85644c89c355fe68678a62c17, I have reviewed the code and it looks OK, I agree it can be merged.

    New comparison operator signatures follow reference prototypes.

    Did not test with actual compiling with std=c++20.

  7. fanquake merged this on Feb 23, 2022
  8. fanquake closed this on Feb 23, 2022

  9. MarcoFalke deleted the branch on Feb 23, 2022
  10. sidhujag referenced this in commit 7b117f4c33 on Feb 23, 2022
  11. DrahtBot locked this on Feb 23, 2023
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me