Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-60031

RadixStore::radix_iterator [in]equality operators should be declared const

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • Execution Team 2021-12-13

      The RadixStore::radix_iterator class defines operator== and operator!= without declaring them const. When building in C++20 mode, clang-12 complains:

      src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_sorted_impl.cpp:952:24: error: ISO C++20 considers use of overloaded operator '==' (with operand types 'StringStore::const_iterator' (aka 'radix_iterator<const std::pair<const std::basic_string<char>, std::basic_string<char>> *, const pair<const std::basic_string<char>, std::basic_string<char>> &>') and 'mongo::ephemeral_for_test::RadixStore<std::basic_string<char>, std::basic_string<char>>::const_iterator' (aka 'radix_iterator<const std::pair<const std::basic_string<char>, std::basic_string<char>> *, const pair<const std::basic_string<char>, std::basic_string<char>> &>')) to be ambiguous despite there being a unique best viable function [-Werror,-Wambiguous-reversed-operator]
              if (_forwardIt == _workingCopy->end()) {
                  ~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~
      src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_radix_store.h:148:14: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
              bool operator==(const radix_iterator& other) {
                   ^
      

      The iterator class should be re-worked to allow the [in]equality operators to be defined as const. In the meantime, we will suppress this warning.

            Assignee:
            yuhong.zhang@mongodb.com Yuhong Zhang
            Reporter:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: