[SERVER-60031] RadixStore::radix_iterator [in]equality operators should be declared const Created: 16/Sep/21  Updated: 29/Oct/23  Resolved: 02/Dec/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-61874 Complete TODO listed in SERVER-60031 Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2021-12-13
Participants:

 Description   

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.



 Comments   
Comment by Billy Donahue [ 07/Dec/21 ]

This iterator needs to be refactored, and it sounds like this isn't news to anyone .

I just want to point out that in an a==b expression, the repositionIfChanged resync is only performed on a.
This behavior is in place before and after the recent PR 2150.

Comment by Githook User [ 04/Dec/21 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'danielzhangyh@gmail.com', 'username': 'YuhongZhang98'}

Message: SERVER-60031 Remove todo in EFT SConscript
Branch: master
https://github.com/mongodb/mongo/commit/9962e86ee60965b4b0d336206ef3604f9a33644b

Comment by Githook User [ 02/Dec/21 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'danielzhangyh@gmail.com', 'username': 'YuhongZhang98'}

Message: SERVER-60031 Declare RadixStore iterators [in]equality operators const
Branch: master
https://github.com/mongodb/mongo/commit/968a1b11ad2b8972471b008fdd42f92f8ce50c55

Comment by Connie Chen [ 01/Nov/21 ]

Short term solution: make const and add mutable where needed.

Generated at Thu Feb 08 05:48:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.